Loading ...
Sorry, an error occurred while loading the content.
 

Few queries .. very basic

Expand Messages
  • Sreeram B S
    Hi Friends, I am hereby posting few very basic queries. I have made sincere efforts in getting them solved but somehow could not get to closure. (a) In perl,
    Message 1 of 11 , Aug 31, 2005
      Hi Friends,
      I am hereby posting few very basic queries. I have made sincere efforts in getting them solved but somehow could not get to closure.

      (a) In perl, is there any method to compare characters? Here, I am not speaking of string-comparison. We do have a lot of operators for comparing strings. But, how do I compare characters. ie single character to another single character.
      For eg: How can I know whether the user has pressed the <ENTER> key?

      (b) From the perlfaq man pages, I read the line "get the module from your nearest CPAN" quite often. One such example module is Term::ReadKey. This module seems to be very helpful when dealing with keyboard entries .. etc. But when I tried to: use Term::ReadKey; , I was given the error:
      Can't locate Term/ReadKey.pm in @INC (@INC contains: /usr/local/lib/perl5/5.6.1/sun4-solaris /usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .) at onechar.p line 2.
      BEGIN failed--compilation aborted at onechar.p line 2.
      How can I get such important modules from the CPAN. What is the procedure to be followed?

      Request: Kindly dont get irked, if you feel that these questions are not supposed to be posted in this forum. I am making my efforts to make myself comfortable in Perl.

      Kindly inform.

      Thanks,
      Sreeram


      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com

      [Non-text portions of this message have been removed]
    • Charles K. Clarkson
      ... In perl, characters are strings. String comparison operators work for individual characters as well as multiple characters. Why are you trying to read
      Message 2 of 11 , Aug 31, 2005
        Sreeram B S <> wrote:

        : (a) In perl, is there any method to compare characters? Here, I
        : am not speaking of string-comparison. We do have a lot of
        : operators for comparing strings. But, how do I compare
        : characters. ie single character to another single character.

        In perl, characters are strings. String comparison operators
        work for individual characters as well as multiple characters.
        Why are you trying to read individual characters from the
        terminal?


        : How can I get such important modules from the CPAN. What is
        : the procedure to be followed?

        http://www.cpan.org/misc/cpan-faq.html#Where_find_Perl_modules


        HTH,

        Charles K. Clarkson
        --
        Mobile Homes Specialist
        254 968-8328
      • Sreeram B S
        Down posting ... [There is some trouble with the module install.] Charles K. Clarkson wrote: ... In perl, characters are strings.
        Message 3 of 11 , Sep 1, 2005
          Down posting ... [There is some trouble with the module install.]

          "Charles K. Clarkson" <cclarkson@...> wrote:

          Sreeram B S <> wrote:

          : (a) In perl, is there any method to compare characters? Here, I
          : am not speaking of string-comparison. We do have a lot of
          : operators for comparing strings. But, how do I compare
          : characters. ie single character to another single character.

          In perl, characters are strings. String comparison operators
          work for individual characters as well as multiple characters.
          Why are you trying to read individual characters from the
          terminal?


          : How can I get such important modules from the CPAN. What is
          : the procedure to be followed?

          http://www.cpan.org/misc/cpan-faq.html#Where_find_Perl_modules


          Hi Charles,

          I could get the required module from the CPAN. I followed the install procedure documented in perlmodinstall manual page. I am using Solaris. I am finding trouble in installing the module. The steps (just for your quick reference) are:

          (a) Unzip and untar - Done successfully.

          (b) perl MakeFile.PL - Done successfully. [ I used PREFIX here]

          (c) make - FAILURE !!

          login3:~/personal/perl/installs/TermReadKey-2.30 > make
          cc -c -xO3 -xdepend -DVERSION=\"2.30\" -DXS_VERSION=\"2.30\" -KPIC -I/usr/perl5/5.00503/sun4-solaris/CORE ReadKey.c
          /usr/ucb/cc: language optional software package not installed
          *** Error code 1
          make: Fatal error: Command failed for target `ReadKey.o'
          login3:~/personal/perl/installs/TermReadKey-2.30 >

          How do I correct this? What needs to be changed. Kindly suggest.

          Thanks,

          Sreeram



          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com

          [Non-text portions of this message have been removed]
        • merlyn@stonehenge.com
          ... Sreeram Down posting ... [There is some trouble with the module install.] TRIM it. TRIM it. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc.
          Message 4 of 11 , Sep 1, 2005
            >>>>> "Sreeram" == Sreeram B S <sreeramabsc@...> writes:

            Sreeram> Down posting ... [There is some trouble with the module install.]

            TRIM it. TRIM it.

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
            See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
          • Shawn Corey
            ... Use the split operator rather than substr. The resulting code will be faster and easier to read. my @chars = split //, $string; Then use $chars[$i] rather
            Message 5 of 11 , Sep 1, 2005
              Charles K. Clarkson wrote:
              > In perl, characters are strings. String comparison operators
              > work for individual characters as well as multiple characters.

              Use the split operator rather than substr. The resulting code will be
              faster and easier to read.

              my @chars = split //, $string;

              Then use $chars[$i] rather than substr( $string, $i, 1 ).


              --- Shawn
            • Grier Johnson
              ... Solaris doesn t come with a compiler installed. You can either buy Sun One Studio (expensive, not recommended) or grab gcc from sunfreeware.com. I d go
              Message 6 of 11 , Sep 1, 2005
                On 9/1/05, Sreeram B S <sreeramabsc@...> wrote:

                > (a) Unzip and untar - Done successfully.
                >
                > (b) perl MakeFile.PL - Done successfully. [ I used PREFIX here]
                >
                > (c) make - FAILURE !!
                >
                > login3:~/personal/perl/installs/TermReadKey-2.30 > make
                > cc -c -xO3 -xdepend -DVERSION=\"2.30\" -DXS_VERSION=\"2.30\" -KPIC -I/usr/perl5/5.00503/sun4-solaris/CORE ReadKey.c
                > /usr/ucb/cc: language optional software package not installed
                > *** Error code 1
                > make: Fatal error: Command failed for target `ReadKey.o'
                > login3:~/personal/perl/installs/TermReadKey-2.30 >
                >
                > How do I correct this? What needs to be changed. Kindly suggest.

                Solaris doesn't come with a compiler installed. You can either buy
                Sun One Studio (expensive, not recommended) or grab gcc from
                sunfreeware.com.

                I'd go with the latter one as it's free and should work ok for most needs.

                --
                Grier
              • Damien Carbery
                ... needs. ... Sun Studio 10 is available for free from http://www.opensolaris.org/os/community/tools/sun_studio_tools/ I suggesting going with Sun Studio 10
                Message 7 of 11 , Sep 1, 2005
                  --- In perl-beginner@yahoogroups.com, Grier Johnson <grierj@g...> wrote:
                  > Solaris doesn't come with a compiler installed. You can either buy
                  > Sun One Studio (expensive, not recommended) or grab gcc from
                  > sunfreeware.com.
                  >
                  > I'd go with the latter one as it's free and should work ok for most
                  needs.
                  >
                  > --
                  > Grier

                  Sun Studio 10 is available for free from
                  http://www.opensolaris.org/os/community/tools/sun_studio_tools/

                  I suggesting going with Sun Studio 10 because it is actively maintain
                  while I'm not sure about gcc on Solaris.
                • Grier Johnson
                  ... I stand corrected. If it s free, stick to the sun product. -- Grier
                  Message 8 of 11 , Sep 1, 2005
                    On 9/1/05, Damien Carbery <daymobrew@...> wrote:

                    > Sun Studio 10 is available for free from
                    > http://www.opensolaris.org/os/community/tools/sun_studio_tools/
                    >
                    > I suggesting going with Sun Studio 10 because it is actively maintain
                    > while I'm not sure about gcc on Solaris.

                    I stand corrected. If it's free, stick to the sun product.

                    --
                    Grier
                  • Sreeram B S
                    Grier Johnson wrote: ... Solaris doesn t come with a compiler installed. You can either buy Sun One Studio (expensive, not recommended) or
                    Message 9 of 11 , Sep 1, 2005
                      Grier Johnson <grierj@...> wrote:
                      On 9/1/05, Sreeram B S <sreeramabsc@...> wrote:

                      > (a) Unzip and untar - Done successfully.
                      >
                      > (b) perl MakeFile.PL - Done successfully. [ I used PREFIX here]
                      >
                      > (c) make - FAILURE !!
                      >
                      > login3:~/personal/perl/installs/TermReadKey-2.30 > make
                      > cc -c -xO3 -xdepend -DVERSION=\"2.30\" -DXS_VERSION=\"2.30\" -KPIC -I/usr/perl5/5.00503/sun4-solaris/CORE ReadKey.c
                      > /usr/ucb/cc: language optional software package not installed
                      > *** Error code 1
                      > make: Fatal error: Command failed for target `ReadKey.o'
                      > login3:~/personal/perl/installs/TermReadKey-2.30 >
                      >
                      > How do I correct this? What needs to be changed. Kindly suggest.

                      Solaris doesn't come with a compiler installed. You can either buy
                      Sun One Studio (expensive, not recommended) or grab gcc from
                      sunfreeware.com.

                      I'd go with the latter one as it's free and should work ok for most needs.

                      --
                      Grier

                      Hi,

                      I am thankful to you for your suggestions. However, I have one query here. I do have gcc in my system. But the Makefile in the module ( ie Perl module for Term::ReadKey), is internally using "cc". I could not trace out as to how to make this Makefile compatible with gcc.

                      Do we have any methods for getting modules from CPAN, which are gcc compatible?

                      Kindly suggest,

                      Thanks,

                      Sreeram





                      ---------------------------------
                      Start your day with Yahoo! - make it your home page

                      [Non-text portions of this message have been removed]
                    • acummingsus
                      ... [ snip stuff about Solaris and if has compiler or not ] ... [ snip ] ... My Slackware 10.1 uses gcc. But cc also works (can use) due to a symlink pointing
                      Message 10 of 11 , Sep 1, 2005
                        --- In perl-beginner@yahoogroups.com, Sreeram B S
                        <sreeramabsc@y...> wrote:
                        >
                        >
                        > Grier Johnson <grierj@g...> wrote: On 9/1/05, Sreeram B S
                        > <sreeramabsc@y...> wrote:
                        >
                        > > [ snip ]
                        [ snip stuff about Solaris and if has compiler or not ]
                        > --
                        > Grier
                        [ snip ]
                        > [snip]. I do have gcc in my system. But the Makefile in the
                        > module ( ie Perl module for Term::ReadKey), is internally using
                        > "cc". I could not trace out as to how to make this Makefile
                        > compatible with gcc.
                        >
                        > Do we have any methods for getting modules from CPAN, which are gcc
                        > compatible?

                        My Slackware 10.1 uses gcc. But cc also works (can use) due to a
                        symlink pointing from cc to gcc. Thus:

                        al@p2bs103:~$ which cc
                        /usr/bin/cc
                        al@p2bs103:~$ which gcc
                        /usr/bin/gcc
                        al@p2bs103:~$ ls -la /usr/bin/cc
                        lrwxrwxrwx 1 root root 3 2005-02-21 22:33 /usr/bin/cc -> gcc*
                        al@p2bs103:~$ ls -la /usr/bin/gcc
                        lrwxrwxrwx 1 root root 9 2005-02-21 22:33 /usr/bin/gcc -> gcc-3.3.4*
                        al@p2bs103:~$

                        (yes, an Asus P2BS scsi motherboard version 1.03, Intel BX chipset,
                        circa 1998, 1999)

                        Unmodified Slackware 10.1
                        --

                        (to heck with "man ln"). slink (sym link) helper tool I wrote for me
                        who never remembers how to make a sym link. (I don't know if you need
                        to create a sym link of cc that points to gcc).

                        A Perl I wrote, named it slink:

                        #!/usr/bin/perl -w

                        # ln -s /usr/local/Adobe/Acrobat7.0/bin/acroread acroread
                        use strict;

                        print <<STUF;

                        Creates a sym link
                        Useage: must be root; cd to where want the link to reside;
                        (usually in the search path)
                        at prompt enter: /usr/local/bin/perl perl
                        done in /usr/bin that makes
                        /usr/bin/perl point to /usr/local/bin/perl
                        (runs ln -s /path/dir/file_name file_name)
                        which gets the command syntax correct for me

                        OR enter q to exit/cancel
                        STUF
                        print "\nenter /path/file_name file_name: ";
                        chomp(my $path_w_name = <STDIN>);
                        while (1) {
                        last if $path_w_name =~ /q/;
                        system("ln -s $path_w_name");
                        # print "$path_w_name";
                        last;
                        }
                        if ($path_w_name =~ /q/) {
                        print "\ncanceled\n"; }
                        print "\n";
                        # end

                        --
                        Alan.
                      • acummingsus
                        ... [ snip ] ... last if $path_w_name =~ / bq b/; # better in case of q within string [ snip ] ... if ($path_w_name =~ / bq b/) { # better in case of q within
                        Message 11 of 11 , Sep 2, 2005
                          --- In perl-beginner@yahoogroups.com, "acummingsus" <acelists@g...> wrote:
                          [ snip ]
                          > last if $path_w_name =~ /q/;

                          last if $path_w_name =~ /\bq\b/; # better in case of q within string

                          [ snip ]
                          > if ($path_w_name =~ /q/) {

                          if ($path_w_name =~ /\bq\b/) { # better in case of q within string

                          Not best. Not yet anyways. Good enuff works for me.

                          --
                          Alan.
                        Your message has been successfully submitted and would be delivered to recipients shortly.