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

RE: [PBML] Problems with @ARGV

Expand Messages
  • Bobby Jafari
    Thanks Jabir, I makes much more sense now. Best regards, Bobby ________________________________ From: perl-beginner@yahoogroups.com on behalf of jabir ahmed
    Message 1 of 3 , Oct 8, 2005
      Thanks Jabir,

      I makes much more sense now.

      Best regards,
      Bobby

      ________________________________

      From: perl-beginner@yahoogroups.com on behalf of jabir ahmed
      Sent: Sat 10/8/2005 8:29 PM
      To: perl-beginner@yahoogroups.com
      Subject: Re: [PBML] Problems with @ARGV



      On 10/8/05, Bobby Jafari <bobby.jafari@...> wrote:
      > Hi All,

      > I have the following code:

      > #!/usr/bin/perl
      > #---------------------#
      > # PROGRAM: argv.pl #
      > #---------------------#
      > print ("\nThanks, you gave me ", ($#ARGV + 1), " command-line arguments.\n");
      > foreach (@ARGV)
      > {
      > print "\n $ARGV[$_] \n";
      > }
      >
      > In Windows active perl executing the following:
      >
      > argv.pl 1 2 3 4 5
      >
      > and get the following:
      >
      > Thanks, you gave me 5 command-line arguments.
      > 2
      > 3
      > 4
      > 5
      >
      > Any ideas why its skipping 1
      >
      > Best regards,
      > Bobby

      hello

      because $_ contains the value of the variable and not the index value

      you should try

      foreach (@ARGV)
      {
      print "\n $_ \n";
      }

      to print all the elements of the array.

      and the exp of ur problem is
      $ARGV[1] contains 2
      $ARGV[2] contains 3
      $ARGV[3] contains 4
      $ARGV[4] contains 5
      $ARGV[5] contains

      thats y u get
      2
      3
      4
      5
      <<<BLANK LINE>>>
      rgds
      jabir

      >
      > ________________________________




      --
      It matters not whether you win or lose; what matters is whether I win or lose.
      Phone: +91 98867 01148
      email: jabirahmed@... , jabirahmed@...
      Instant Messenger:
      yahoo jabirahmed@...,msn : jabir07@...,ICQ: 56327312,
      Skype: jabirahmed



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












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