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

Re: [PBML]

Expand Messages
  • Shawn H Corey
    ... You have to press ENTER after you type the response. -- Just my 0.00000002 million dollars worth, Shawn Confusion is the first step of understanding.
    Message 1 of 20 , Sep 27, 2011
    • 0 Attachment
      On 11-09-27 06:09 AM, medura43 wrote:
      > When I type in my response, it appears to be waiting.

      You have to press ENTER after you type the response.


      --
      Just my 0.00000002 million dollars worth,
      Shawn

      Confusion is the first step of understanding.

      Programming is as much about organization and communication
      as it is about coding.

      The secret to great software: Fail early & often.

      Eliminate software piracy: use only FLOSS.

      "Make something worthwhile." -- Dear Hunter
    • medura43
      All good, thats why I joined this group. Yes and I did press after I typed in my answer. appreciate all comments.:) Heading off now, but I hope to
      Message 2 of 20 , Sep 27, 2011
      • 0 Attachment
        All good, thats why I joined this group. Yes and I did press <enter> after I typed in my answer.

        appreciate all comments.:)

        Heading off now, but I hope to catch up with you all tomorrow. Thanks everybody for your input.


        --- In perl-beginner@yahoogroups.com, "Rajagopal, Jay" <jay_rajagopal@...> wrote:
        >
        > If you are not able to understand $| ie "flush STDOUT buffer", it means, you do not know any programming language and need to read books.
        >
        > Don't take me wrong, I knew all these things, databases and still was jobless and my first salary was, hold your breath, 15 cents an hour.
        >
        > I see some Indian programmers getting 100 times my salary than I got, but still asking elementary questions.
        >
        > Thanks
        > jay
        >
        > -----Original Message-----
        > From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of medura43
        > Sent: Tuesday, September 27, 2011 9:07 AM
        > To: perl-beginner@yahoogroups.com
        > Subject: Re: [PBML] <STDIN>
        >
        > Thanks for your quick reply, that was my mistake when I retyped it in the post. My original script has the ; colon.
        >
        > I have found sites that talk about adding $|; before the <STDIN>. But this does not appear to make any difference.
        >
        > I have now included the use strict statement in my script.
        >
        > --- In perl-beginner@yahoogroups.com, Alan Haggai Alavi <alanhaggai@> wrote:
        > >
        > > Hello,
        > >
        > > On 09/27/11 15:39, medura43 wrote:
        > > > print "Which device file do you want\n"
        > > > my $name = <STDIN>;
        > > > chomp;
        > > > print "The value is $name \n";
        > > >
        > > > When I type in my response, it appears to be waiting. Not sure what
        > > > the issue would be. I am starting to think that it may be some sort
        > > > of memory issue.
        > > >
        > > > Does anyone have any ideas?
        > >
        > > The script that you posted has a missing semicolon after the first
        > > print statement. `chomp` without any arguments chomps the `$_` variable.
        > > However, the input is in `$name`. `chomp($name)` or `chomp( my $name =
        > > <STDIN> )` shall be used instead.
        > >
        > > Revised program:
        > >
        > > use strict;
        > > use warnings;
        > >
        > > print "Which device file do you want?\n";
        > > chomp( my $name = <STDIN> );
        > > print "The value is '$name'.\n";
        > >
        > > Regards,
        > > Alan Haggai Alavi.
        > > --
        > > The difference makes the difference.
        > >
        >
        >
        >
        >
        > ------------------------------------
        >
        > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
        >
        >
        >
        >
        > T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.
        >
        > The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
        >
      • medura43
        Here is my script. It is running on Redhat 4.9 perl 5.8.5. Since adding the strict statement, I am getting a few more errors. Particularly around this
        Message 3 of 20 , Sep 27, 2011
        • 0 Attachment
          Here is my script. It is running on Redhat 4.9 perl 5.8.5. Since adding the strict statement, I am getting a few more errors. Particularly around this statement.

          (my $agile, my $legacy) = split(/\s+/, my $device);
          my $legacy{my $agile} = my $legacy;

          __________________________________________________________

          !/usr/bin/perl
          use strict;
          use warnings;

          open(CMD,"<lvmtab.txt");
          undef($/); # Slurps in the lvmtab.txt into the array

          while (<CMD>) {
          my @device = (split/[\n]/);
          }

          foreach my $device (my @device) {
          (my $agile, my $legacy) = split(/\s+/, my $device);
          my $legacy{my $agile} = my $legacy;
          }

          $legacy = (keys my %legacy);

          foreach $agile (keys %legacy) {
          print "$agile:\t$legacy{$agile}\n";
          }
          $|=1;
          print "Which device file do you want\n "; # Test to find out why it
          chomp(my $name = <STDIN>); # hangs
          print "The value is $name \n";

          $hash_len = keys %legacy; # Number of lines in a hash

          print "The following elements\n";
          print "$agile --> $legacy{$agile} $hash_len\n";
          close CMD;


          --- In perl-beginner@yahoogroups.com, "medura43" <medura43@...> wrote:
          >
          > All good, thats why I joined this group. Yes and I did press <enter> after I typed in my answer.
          >
          > appreciate all comments.:)
          >
          > Heading off now, but I hope to catch up with you all tomorrow. Thanks everybody for your input.
          >
          >
          > --- In perl-beginner@yahoogroups.com, "Rajagopal, Jay" <jay_rajagopal@> wrote:
          > >
          > > If you are not able to understand $| ie "flush STDOUT buffer", it means, you do not know any programming language and need to read books.
          > >
          > > Don't take me wrong, I knew all these things, databases and still was jobless and my first salary was, hold your breath, 15 cents an hour.
          > >
          > > I see some Indian programmers getting 100 times my salary than I got, but still asking elementary questions.
          > >
          > > Thanks
          > > jay
          > >
          > > -----Original Message-----
          > > From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of medura43
          > > Sent: Tuesday, September 27, 2011 9:07 AM
          > > To: perl-beginner@yahoogroups.com
          > > Subject: Re: [PBML] <STDIN>
          > >
          > > Thanks for your quick reply, that was my mistake when I retyped it in the post. My original script has the ; colon.
          > >
          > > I have found sites that talk about adding $|; before the <STDIN>. But this does not appear to make any difference.
          > >
          > > I have now included the use strict statement in my script.
          > >
          > > --- In perl-beginner@yahoogroups.com, Alan Haggai Alavi <alanhaggai@> wrote:
          > > >
          > > > Hello,
          > > >
          > > > On 09/27/11 15:39, medura43 wrote:
          > > > > print "Which device file do you want\n"
          > > > > my $name = <STDIN>;
          > > > > chomp;
          > > > > print "The value is $name \n";
          > > > >
          > > > > When I type in my response, it appears to be waiting. Not sure what
          > > > > the issue would be. I am starting to think that it may be some sort
          > > > > of memory issue.
          > > > >
          > > > > Does anyone have any ideas?
          > > >
          > > > The script that you posted has a missing semicolon after the first
          > > > print statement. `chomp` without any arguments chomps the `$_` variable.
          > > > However, the input is in `$name`. `chomp($name)` or `chomp( my $name =
          > > > <STDIN> )` shall be used instead.
          > > >
          > > > Revised program:
          > > >
          > > > use strict;
          > > > use warnings;
          > > >
          > > > print "Which device file do you want?\n";
          > > > chomp( my $name = <STDIN> );
          > > > print "The value is '$name'.\n";
          > > >
          > > > Regards,
          > > > Alan Haggai Alavi.
          > > > --
          > > > The difference makes the difference.
          > > >
          > >
          > >
          > >
          > >
          > > ------------------------------------
          > >
          > > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
          > >
          > >
          > >
          > >
          > > T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.
          > >
          > > The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
          > >
          >
        • Rajagopal, Jay
          Don t use strict. It is not a good practice at your level. Thanks jay ... From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf
          Message 4 of 20 , Sep 27, 2011
          • 0 Attachment
            Don't use strict. It is not a good practice at your level.
            Thanks
            jay

            -----Original Message-----
            From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of medura43
            Sent: Tuesday, September 27, 2011 4:46 PM
            To: perl-beginner@yahoogroups.com
            Subject: Re: [PBML] <STDIN>

            Here is my script. It is running on Redhat 4.9 perl 5.8.5. Since adding the strict statement, I am getting a few more errors. Particularly around this statement.

            (my $agile, my $legacy) = split(/\s+/, my $device);
            my $legacy{my $agile} = my $legacy;

            __________________________________________________________

            !/usr/bin/perl
            use strict;
            use warnings;

            open(CMD,"<lvmtab.txt");
            undef($/); # Slurps in the lvmtab.txt into the array

            while (<CMD>) {
            my @device = (split/[\n]/);
            }

            foreach my $device (my @device) {
            (my $agile, my $legacy) = split(/\s+/, my $device);
            my $legacy{my $agile} = my $legacy;
            }

            $legacy = (keys my %legacy);

            foreach $agile (keys %legacy) {
            print "$agile:\t$legacy{$agile}\n";
            }
            $|=1;
            print "Which device file do you want\n "; # Test to find out why it
            chomp(my $name = <STDIN>); # hangs
            print "The value is $name \n";

            $hash_len = keys %legacy; # Number of lines in a hash

            print "The following elements\n";
            print "$agile --> $legacy{$agile} $hash_len\n"; close CMD;


            --- In perl-beginner@yahoogroups.com, "medura43" <medura43@...> wrote:
            >
            > All good, thats why I joined this group. Yes and I did press <enter> after I typed in my answer.
            >
            > appreciate all comments.:)
            >
            > Heading off now, but I hope to catch up with you all tomorrow. Thanks everybody for your input.
            >
            >
            > --- In perl-beginner@yahoogroups.com, "Rajagopal, Jay" <jay_rajagopal@> wrote:
            > >
            > > If you are not able to understand $| ie "flush STDOUT buffer", it means, you do not know any programming language and need to read books.
            > >
            > > Don't take me wrong, I knew all these things, databases and still was jobless and my first salary was, hold your breath, 15 cents an hour.
            > >
            > > I see some Indian programmers getting 100 times my salary than I got, but still asking elementary questions.
            > >
            > > Thanks
            > > jay
            > >
            > > -----Original Message-----
            > > From: perl-beginner@yahoogroups.com
            > > [mailto:perl-beginner@yahoogroups.com] On Behalf Of medura43
            > > Sent: Tuesday, September 27, 2011 9:07 AM
            > > To: perl-beginner@yahoogroups.com
            > > Subject: Re: [PBML] <STDIN>
            > >
            > > Thanks for your quick reply, that was my mistake when I retyped it in the post. My original script has the ; colon.
            > >
            > > I have found sites that talk about adding $|; before the <STDIN>. But this does not appear to make any difference.
            > >
            > > I have now included the use strict statement in my script.
            > >
            > > --- In perl-beginner@yahoogroups.com, Alan Haggai Alavi <alanhaggai@> wrote:
            > > >
            > > > Hello,
            > > >
            > > > On 09/27/11 15:39, medura43 wrote:
            > > > > print "Which device file do you want\n"
            > > > > my $name = <STDIN>;
            > > > > chomp;
            > > > > print "The value is $name \n";
            > > > >
            > > > > When I type in my response, it appears to be waiting. Not sure
            > > > what
            > > > > the issue would be. I am starting to think that it may be some
            > > > > sort of memory issue.
            > > > >
            > > > > Does anyone have any ideas?
            > > >
            > > > The script that you posted has a missing semicolon after the first
            > > > print statement. `chomp` without any arguments chomps the `$_` variable.
            > > > However, the input is in `$name`. `chomp($name)` or `chomp( my
            > > > $name = <STDIN> )` shall be used instead.
            > > >
            > > > Revised program:
            > > >
            > > > use strict;
            > > > use warnings;
            > > >
            > > > print "Which device file do you want?\n";
            > > > chomp( my $name = <STDIN> );
            > > > print "The value is '$name'.\n";
            > > >
            > > > Regards,
            > > > Alan Haggai Alavi.
            > > > --
            > > > The difference makes the difference.
            > > >
            > >
            > >
            > >
            > >
            > > ------------------------------------
            > >
            > > Unsubscribing info is here:
            > > http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups
            > > Links
            > >
            > >
            > >
            > >
            > > T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.
            > >
            > > The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
            > >
            >




            ------------------------------------

            Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links




            T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.

            The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
          • Rajagopal, Jay
            foreach my $device ( @device) { (my $agile, my $legacy) = split(/ s+/, $device); Try the above. ... From: perl-beginner@yahoogroups.com
            Message 5 of 20 , Sep 27, 2011
            • 0 Attachment
              foreach my $device ( @device) {
              (my $agile, my $legacy) = split(/\s+/, $device);
              Try the above.
              -----Original Message-----
              From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of medura43
              Sent: Tuesday, September 27, 2011 4:46 PM
              To: perl-beginner@yahoogroups.com
              Subject: Re: [PBML] <STDIN>

              Here is my script. It is running on Redhat 4.9 perl 5.8.5. Since adding the strict statement, I am getting a few more errors. Particularly around this statement.

              (my $agile, my $legacy) = split(/\s+/, my $device);
              my $legacy{my $agile} = my $legacy;

              __________________________________________________________

              !/usr/bin/perl
              use strict;
              use warnings;

              open(CMD,"<lvmtab.txt");
              undef($/); # Slurps in the lvmtab.txt into the array

              while (<CMD>) {
              my @device = (split/[\n]/);
              }

              foreach my $device (my @device) {
              (my $agile, my $legacy) = split(/\s+/, my $device);
              my $legacy{my $agile} = my $legacy;
              }

              $legacy = (keys my %legacy);

              foreach $agile (keys %legacy) {
              print "$agile:\t$legacy{$agile}\n";
              }
              $|=1;
              print "Which device file do you want\n "; # Test to find out why it
              chomp(my $name = <STDIN>); # hangs
              print "The value is $name \n";

              $hash_len = keys %legacy; # Number of lines in a hash

              print "The following elements\n";
              print "$agile --> $legacy{$agile} $hash_len\n"; close CMD;


              --- In perl-beginner@yahoogroups.com, "medura43" <medura43@...> wrote:
              >
              > All good, thats why I joined this group. Yes and I did press <enter> after I typed in my answer.
              >
              > appreciate all comments.:)
              >
              > Heading off now, but I hope to catch up with you all tomorrow. Thanks everybody for your input.
              >
              >
              > --- In perl-beginner@yahoogroups.com, "Rajagopal, Jay" <jay_rajagopal@> wrote:
              > >
              > > If you are not able to understand $| ie "flush STDOUT buffer", it means, you do not know any programming language and need to read books.
              > >
              > > Don't take me wrong, I knew all these things, databases and still was jobless and my first salary was, hold your breath, 15 cents an hour.
              > >
              > > I see some Indian programmers getting 100 times my salary than I got, but still asking elementary questions.
              > >
              > > Thanks
              > > jay
              > >
              > > -----Original Message-----
              > > From: perl-beginner@yahoogroups.com
              > > [mailto:perl-beginner@yahoogroups.com] On Behalf Of medura43
              > > Sent: Tuesday, September 27, 2011 9:07 AM
              > > To: perl-beginner@yahoogroups.com
              > > Subject: Re: [PBML] <STDIN>
              > >
              > > Thanks for your quick reply, that was my mistake when I retyped it in the post. My original script has the ; colon.
              > >
              > > I have found sites that talk about adding $|; before the <STDIN>. But this does not appear to make any difference.
              > >
              > > I have now included the use strict statement in my script.
              > >
              > > --- In perl-beginner@yahoogroups.com, Alan Haggai Alavi <alanhaggai@> wrote:
              > > >
              > > > Hello,
              > > >
              > > > On 09/27/11 15:39, medura43 wrote:
              > > > > print "Which device file do you want\n"
              > > > > my $name = <STDIN>;
              > > > > chomp;
              > > > > print "The value is $name \n";
              > > > >
              > > > > When I type in my response, it appears to be waiting. Not sure
              > > > what
              > > > > the issue would be. I am starting to think that it may be some
              > > > > sort of memory issue.
              > > > >
              > > > > Does anyone have any ideas?
              > > >
              > > > The script that you posted has a missing semicolon after the first
              > > > print statement. `chomp` without any arguments chomps the `$_` variable.
              > > > However, the input is in `$name`. `chomp($name)` or `chomp( my
              > > > $name = <STDIN> )` shall be used instead.
              > > >
              > > > Revised program:
              > > >
              > > > use strict;
              > > > use warnings;
              > > >
              > > > print "Which device file do you want?\n";
              > > > chomp( my $name = <STDIN> );
              > > > print "The value is '$name'.\n";
              > > >
              > > > Regards,
              > > > Alan Haggai Alavi.
              > > > --
              > > > The difference makes the difference.
              > > >
              > >
              > >
              > >
              > >
              > > ------------------------------------
              > >
              > > Unsubscribing info is here:
              > > http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups
              > > Links
              > >
              > >
              > >
              > >
              > > T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.
              > >
              > > The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
              > >
              >




              ------------------------------------

              Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links




              T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.

              The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
            • Shawn H Corey
              ... Always `use strict;` Always `use warnings;` -- Just my 0.00000002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is
              Message 6 of 20 , Sep 27, 2011
              • 0 Attachment
                On 11-09-27 04:56 PM, Rajagopal, Jay wrote:
                > Don't use strict.

                Always `use strict;`

                Always `use warnings;`


                --
                Just my 0.00000002 million dollars worth,
                Shawn

                Confusion is the first step of understanding.

                Programming is as much about organization and communication
                as it is about coding.

                The secret to great software: Fail early & often.

                Eliminate software piracy: use only FLOSS.

                "Make something worthwhile." -- Dear Hunter
              • Shawn H Corey
                ... # use the three argument open and test for success open my $cmd_fh,
                Message 7 of 20 , Sep 27, 2011
                • 0 Attachment
                  On 11-09-27 04:46 PM, medura43 wrote:
                  >
                  > !/usr/bin/perl
                  > use strict;
                  > use warnings;
                  >
                  > open(CMD,"<lvmtab.txt");

                  # use the three argument open and test for success
                  open my $cmd_fh, '<', 'lvmtab.txt' or die "could not open lvmtab.txt: $!\n";

                  > undef($/); # Slurps in the lvmtab.txt into the array
                  >
                  > while (<CMD>) {
                  > my @device = (split/[\n]/);
                  > }

                  # replace the loop with:
                  my @dvice = <$cmd_fh>;

                  # always close your files
                  close $cmd_fh or die "could not close lvmtab.txt: $!\n";

                  >
                  > foreach my $device (my @device) {
                  > (my $agile, my $legacy) = split(/\s+/, my $device);

                  # too many `my`s
                  my ( $agile, $legacy ) = split /\s+/, $device;

                  __END__

                  From this point on, the script does not make sense.

                  > my $legacy{my $agile} = my $legacy;
                  > }

                  1. Closing the loop means it does do anything useful.

                  >
                  > $legacy = (keys my %legacy);

                  2. %legacy does not contain anything.

                  >
                  > foreach $agile (keys %legacy) {

                  3. %legacy is empty, this loop is skipped.

                  > print "$agile:\t$legacy{$agile}\n";
                  > }
                  > $|=1;

                  4. Don't do this; it only slows down your program.

                  > print "Which device file do you want\n "; # Test to find out why it
                  > chomp(my $name = <STDIN>); # hangs
                  > print "The value is $name \n";
                  >
                  > $hash_len = keys %legacy; # Number of lines in a hash

                  5. No, the number of keys in the hash, which is zero.

                  >
                  > print "The following elements\n";
                  > print "$agile --> $legacy{$agile} $hash_len\n";
                  > close CMD;


                  --
                  Just my 0.00000002 million dollars worth,
                  Shawn

                  Confusion is the first step of understanding.

                  Programming is as much about organization and communication
                  as it is about coding.

                  The secret to great software: Fail early & often.

                  Eliminate software piracy: use only FLOSS.

                  "Make something worthwhile." -- Dear Hunter
                • Rajagopal, Jay
                  I have professional programming experience in PERL for 10 years. If a person does not know between a reference and a declaration, DON T USE STRICT. ... From:
                  Message 8 of 20 , Sep 27, 2011
                  • 0 Attachment
                    I have professional programming experience in PERL for 10 years.

                    If a person does not know between a reference and a declaration, DON'T USE STRICT.

                    -----Original Message-----
                    From: Shawn H Corey [mailto:shawnhcorey@...]
                    Sent: Tuesday, September 27, 2011 5:40 PM
                    To: perl-beginner@yahoogroups.com
                    Cc: Rajagopal, Jay
                    Subject: Re: [PBML] <STDIN>

                    On 11-09-27 04:56 PM, Rajagopal, Jay wrote:
                    > Don't use strict.

                    Always `use strict;`

                    Always `use warnings;`


                    --
                    Just my 0.00000002 million dollars worth,
                    Shawn

                    Confusion is the first step of understanding.

                    Programming is as much about organization and communication as it is about coding.

                    The secret to great software: Fail early & often.

                    Eliminate software piracy: use only FLOSS.

                    "Make something worthwhile." -- Dear Hunter

                    T. Rowe Price (including T. Rowe Price Group, Inc. and its affiliates) and its associates do not provide legal or tax advice. Any tax-related discussion contained in this e-mail, including any attachments, is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding any tax penalties or (ii) promoting, marketing, or recommending to any other party any transaction or matter addressed herein. Please consult your independent legal counsel and/or professional tax advisor regarding any legal or tax issues raised in this e-mail.

                    The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail.
                  • Shawn H Corey
                    ... Excellent. I like to see young people having an interest in Perl. BTW, I ve been programming in Perl since version 4. ... What does that have to do with
                    Message 9 of 20 , Sep 27, 2011
                    • 0 Attachment
                      On 11-09-27 05:53 PM, Rajagopal, Jay wrote:
                      > I have professional programming experience in PERL for 10 years.

                      Excellent. I like to see young people having an interest in Perl. BTW,
                      I've been programming in Perl since version 4.

                      >
                      > If a person does not know between a reference and a declaration, DON'T USE STRICT.

                      What does that have to do with it? There are some good reasons to use
                      strict:

                      1. It catches spelling mistakes of any variable.

                      2. It doesn't allow symbolic references. Symbolic references can
                      inadvertently overwrite variables with strange values. This is a bug
                      that's hard to diagnose.

                      `use strict;` and `use warnings;` are recommended Perl's best practices.

                      BTW, you can `use diagnostics;` instead of `use warnings;`. It gives a
                      lengthier warning message but does the same thing.
                    • Amish Husain
                      I completely agree on this, I have always used -w /use strict. Its always a good programming practice and this will help you write better/cleaner code.
                      Message 10 of 20 , Sep 27, 2011
                      • 0 Attachment
                        I completely agree on this, I have always used -w /use strict. Its always a good programming practice and this will help you write better/cleaner code.


                        ________________________________
                        From: Shawn H Corey <shawnhcorey@...>
                        To: perl-beginner@yahoogroups.com
                        Cc: "Rajagopal, Jay" <jay_rajagopal@...>
                        Sent: Tuesday, September 27, 2011 5:40 PM
                        Subject: Re: [PBML] <STDIN>


                         
                        On 11-09-27 04:56 PM, Rajagopal, Jay wrote:
                        > Don't use strict.

                        Always `use strict;`

                        Always `use warnings;`

                        --
                        Just my 0.00000002 million dollars worth,
                        Shawn

                        Confusion is the first step of understanding.

                        Programming is as much about organization and communication
                        as it is about coding.

                        The secret to great software: Fail early & often.

                        Eliminate software piracy: use only FLOSS.

                        "Make something worthwhile." -- Dear Hunter



                        [Non-text portions of this message have been removed]
                      • merlyn@stonehenge.com
                        ... Rajagopal I have professional programming experience in PERL for 10 Rajagopal years. No you don t. If you still call it PERL , you ve *never* been a
                        Message 11 of 20 , Sep 28, 2011
                        • 0 Attachment
                          >>>>> "Rajagopal" == Rajagopal, Jay <jay_rajagopal@...> writes:

                          Rajagopal> I have professional programming experience in PERL for 10
                          Rajagopal> years.

                          No you don't. If you still call it "PERL", you've *never* been a
                          professional.

                          Please don't lie like that.

                          --
                          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                          Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                          See http://methodsandmessages.posterous.com/ for Smalltalk discussion
                        • medura43
                          Thank your for all your help, I am going to have a close look at all your comments.
                          Message 12 of 20 , Sep 28, 2011
                          • 0 Attachment
                            Thank your for all your help, I am going to have a close look at all your comments.

                            --- In perl-beginner@yahoogroups.com, merlyn@... wrote:
                            >
                            > >>>>> "Rajagopal" == Rajagopal, Jay <jay_rajagopal@...> writes:
                            >
                            > Rajagopal> I have professional programming experience in PERL for 10
                            > Rajagopal> years.
                            >
                            > No you don't. If you still call it "PERL", you've *never* been a
                            > professional.
                            >
                            > Please don't lie like that.
                            >
                            > --
                            > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                            > <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                            > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                            > See http://methodsandmessages.posterous.com/ for Smalltalk discussion
                            >
                          • andy_bach@wiwb.uscourts.gov
                            while ( ) { my @device = (split/[ n]/); } Unfortunatley, the my here means @device goes way outside the while loop my @device; while ( ) { @device =
                            Message 13 of 20 , Sep 28, 2011
                            • 0 Attachment
                              while (<CMD>) {
                              my @device = (split/[\n]/);
                              }

                              Unfortunatley, the 'my' here means @device goes way outside the while loop
                              my @device;
                              while (<CMD>) {
                              @device = (split/[\n]/);
                              }

                              same as:
                              my @device = <CMD>;

                              as the <...> splits on \n for you.

                              >> Too many "my"s ... From this point on, the script does not make sense.

                              (my $agile, my $legacy) = split(/\s+/, my $device);
                              my $legacy{my $agile} = my $legacy;

                              Yeah, you need to first declare the hash (as a hash, that is, w/ the '%')
                              and then assign to it:
                              my ($agile, $legacy) = split(/\s+/, $device);
                              my %legacy;
                              $legacy{$agile} = $legacy;

                              'my' is only needed once per variable - it marks the variable as
                              'lexically scoped' but it doesn't need to be part of any further use.
                              Both:
                              my @device;
                              @device = <CMD>;

                              and:
                              my @device = <CMD>;

                              are basically the same. After that you can just use @device (or
                              $device[1] etc) as needed. "@devices" plural, is a better name (see
                              below).

                              It is silly/bad to use the same name for different vars unless there's
                              really really a strong reason ... can't imagine one. So using legacy as a
                              hash and a scalar var name will only confuse you more, later on. I often
                              just pluralize whatever's in there (assuming 'legacy' refers to some old
                              device name?)
                              my %legacy_devices;
                              $legacy_devices{$agile} = $legacy;

                              "Perl Best Practices" suggests naming hash to reflect the fact that they
                              are generally used as single objects ( $hash_name{$key} vs %hash_name -
                              unlike arrays which are often used as collectives, e.g. @devices vs
                              $devices[2]) so use a singular noun and a preposition (examples given:
                              %title_of
                              %count_for
                              %is_available

                              ) - a great book (Damian Conway, O'Reilly, natch) but we all can't be as
                              consistenly clever as Mr. Conway, even in our dreams.

                              Seems the next part you want is to get a name from the user and see if
                              that is a key to your hash - you're close there, but:

                              print "Which device file do you want\n "; # Test to find out why it
                              chomp(my $name = <STDIN>); # hangs
                              print "The value is $name \n";

                              $hash_len = keys %legacy; # Number of lines in a hash
                              print "The following elements\n";
                              print "$agile --> $legacy{$agile} $hash_len\n";

                              I think you want:
                              print "$name --> $legacy_devices{$name} $hash_len\n";

                              so:
                              if ( exist $legacy_devices{$name} ) {
                              print "$name --> $legacy_devices{$name}\n";
                              }
                              else {
                              print "Sorry $name is not in our legacy devices list (length:
                              $hash_len)\n";
                              }

                              or something.
                              ----------------------
                              Andy Bach
                              Systems Mangler
                              Internet: andy_bach@...
                              Voice: (608) 261-5738, Cell: (608) 658-1890

                              ?One of the most striking differences between a cat and a lie is that a
                              cat has only nine lives.?
                              Mark Twain, Vice President, American Anti-Imperialist League, and
                              erstwhile writer

                              [Non-text portions of this message have been removed]
                            • Paul.G
                              Thanks again, going through your comments. The reason, I interchange the var legacy and device. Is because, I am attempting to separate legacy device names
                              Message 14 of 20 , Sep 30, 2011
                              • 0 Attachment
                                Thanks again, going through your comments.

                                The reason, I interchange the var legacy and device. Is because, I am attempting to separate legacy device names from agile names. Agile names become the key in a hash for legacy devices.

                                for eg:
                                /dev/disk/disk43   /dev/dsk/c4t5d6

                                c4t5d6 is the legacy device name for disk43

                                cheers



                                ________________________________
                                From: "andy_bach@..." <andy_bach@...>
                                To: perl-beginner@yahoogroups.com
                                Sent: Thursday, 29 September 2011 1:51 AM
                                Subject: [PBML] Re: <STDIN>


                                 
                                while (<CMD>) {
                                my @device = (split/[\n]/);
                                }

                                Unfortunatley, the 'my' here means @device goes way outside the while loop
                                my @device;
                                while (<CMD>) {
                                @device = (split/[\n]/);
                                }

                                same as:
                                my @device = <CMD>;

                                as the <...> splits on \n for you.

                                >> Too many "my"s ... From this point on, the script does not make sense.

                                (my $agile, my $legacy) = split(/\s+/, my $device);
                                my $legacy{my $agile} = my $legacy;

                                Yeah, you need to first declare the hash (as a hash, that is, w/ the '%')
                                and then assign to it:
                                my ($agile, $legacy) = split(/\s+/, $device);
                                my %legacy;
                                $legacy{$agile} = $legacy;

                                'my' is only needed once per variable - it marks the variable as
                                'lexically scoped' but it doesn't need to be part of any further use.
                                Both:
                                my @device;
                                @device = <CMD>;

                                and:
                                my @device = <CMD>;

                                are basically the same. After that you can just use @device (or
                                $device[1] etc) as needed. "@devices" plural, is a better name (see
                                below).

                                It is silly/bad to use the same name for different vars unless there's
                                really really a strong reason ... can't imagine one. So using legacy as a
                                hash and a scalar var name will only confuse you more, later on. I often
                                just pluralize whatever's in there (assuming 'legacy' refers to some old
                                device name?)
                                my %legacy_devices;
                                $legacy_devices{$agile} = $legacy;

                                "Perl Best Practices" suggests naming hash to reflect the fact that they
                                are generally used as single objects ( $hash_name{$key} vs %hash_name -
                                unlike arrays which are often used as collectives, e.g. @devices vs
                                $devices[2]) so use a singular noun and a preposition (examples given:
                                %title_of
                                %count_for
                                %is_available

                                ) - a great book (Damian Conway, O'Reilly, natch) but we all can't be as
                                consistenly clever as Mr. Conway, even in our dreams.

                                Seems the next part you want is to get a name from the user and see if
                                that is a key to your hash - you're close there, but:

                                print "Which device file do you want\n "; # Test to find out why it
                                chomp(my $name = <STDIN>); # hangs
                                print "The value is $name \n";

                                $hash_len = keys %legacy; # Number of lines in a hash
                                print "The following elements\n";
                                print "$agile --> $legacy{$agile} $hash_len\n";

                                I think you want:
                                print "$name --> $legacy_devices{$name} $hash_len\n";

                                so:
                                if ( exist $legacy_devices{$name} ) {
                                print "$name --> $legacy_devices{$name}\n";
                                }
                                else {
                                print "Sorry $name is not in our legacy devices list (length:
                                $hash_len)\n";
                                }

                                or something.
                                ----------------------
                                Andy Bach
                                Systems Mangler
                                Internet: andy_bach@...
                                Voice: (608) 261-5738, Cell: (608) 658-1890

                                ?One of the most striking differences between a cat and a lie is that a
                                cat has only nine lives.?
                                Mark Twain, Vice President, American Anti-Imperialist League, and
                                erstwhile writer

                                [Non-text portions of this message have been removed]




                                [Non-text portions of this message have been removed]
                              Your message has been successfully submitted and would be delivered to recipients shortly.