Professional Web Applications Themes

module and $ARGV help - PERL Miscellaneous

<snip> # $t1 = $t1->add($ARGV); } <snip> > I actually tried doing the above but it hung because of the while. > What is the terminating condition for the loop? Or, is there a > better way of doing this? > When my script moves from one file to the next does it update the > value of $ARGV? $ARGV[0] or what every position is applicable. ARGV (an array) is what holds the command line parameters. (from perldoc perlvar) ARGV The array ARGV contains the command-line argu ments intended for the script. $#ARGV is gener ally the number of arguments ...

  1. #1

    Default Re: module and $ARGV help

    <snip>
    # $t1 = $t1->add($ARGV); }
    <snip>
    > I actually tried doing the above but it hung because of the while.
    > What is the terminating condition for the loop? Or, is there a
    > better way of doing this?
    > When my script moves from one file to the next does it update the
    > value of $ARGV?
    $ARGV[0] or what every position is applicable.
    ARGV (an array) is what holds the command line parameters.

    (from perldoc perlvar)

    ARGV The array ARGV contains the command-line argu
    ments intended for the script. $#ARGV is gener
    ally the number of arguments minus one, because
    $ARGV[0] is the first argument, not the program's
    command name itself. See $0 for the command name.

    HTH

    Jim
    James Willmore Guest

  2. #2

    Default Re: module and $ARGV help

    On 25 Jul 2003 10:30:42 -0700, [email]satishigwu.edu[/email] (slash) wrote:
    > #textID=$tb->select(1);
    > #foreach $textID (textID) {
    > # $t1 = $t1->add($ARGV); }
    >I also have another general question about $ARGV.
    >Let's say if I wanted to run the above script over multiple input
    >files. Can I do the following:
    >
    >perl -n script.pl *.TXT
    >
    >I actually tried doing the above but it hung because of the while.
    >What is the terminating condition for the loop? Or, is there a better
    >way of doing this?
    >When my script moves from one file to the next does it update the
    >value of $ARGV?
    $ARGV is updated automatically, but this happens only while the data is
    being read. The earlier line

    my words = split /\W+/, <> ;

    read all the data at once, so $ARGV probably won't be useful after that.
    To be honest, I'm not entirely certain what you're trying to achieve
    with that loop, so I can't say anything more.

    --
    Eric Amick
    Columbia, MD
    Eric Amick Guest

  3. #3

    Default Re: module and $ARGV help

    On Sat, 26 Jul 2003 17:42:52 GMT, Steve Grazzini <grazzpobox.com> wrote:
    >Eric Amick <eric-amickcomcast.net> wrote:
    >> The earlier line
    >>
    >> my words = split /\W+/, <> ;
    >>
    >> read all the data at once, so $ARGV probably won't be useful after
    >> that.
    >
    >That actually puts the readline() into scalar context, so only
    >the first file gets slurped. $ARGV will be the name of the first
    >file afterward.
    I clearly wasn't thinking (again) when I responded. I was having a bad day
    when I wrote that. Yeah, that's it. Bad day. :-)

    --
    Eric Amick
    Columbia, MD
    Eric Amick Guest

  4. #4

    Default Re: module and $ARGV help

    Eric Amick <eric-amickcomcast.net> wrote:


    [ snip code that does not work as intended ]

    > I clearly wasn't thinking (again) when I responded. I was having a bad day
    > when I wrote that. Yeah, that's it. Bad day. :-)

    If you merely test your code (again) before offering it to thousands
    of people around the world, then such a problem can be avoided
    without regard to the goodness of the day in question.

    :-) :-)



    If you don't want to take the time to test it, then at least mark
    it as untested, so folks might be expecting that it does not
    do the Right Thing.


    --
    Tad McClellan SGML consulting
    [email]tadmcaugustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

Similar Threads

  1. PHP 4.3.8: $_SERVER[’argv’] missing
    By steve in forum PHP Development
    Replies: 2
    Last Post: September 29th, 08:34 PM
  2. ARGV question
    By Joe Johnson in forum Ruby
    Replies: 2
    Last Post: October 19th, 08:19 PM
  3. ARGV
    By John Dillon in forum PERL Beginners
    Replies: 2
    Last Post: September 30th, 06:47 PM
  4. Recall: ARGV
    By John Dillon in forum PERL Beginners
    Replies: 0
    Last Post: September 30th, 10:06 AM
  5. first.pl | second.pl with ARGV filehandle ?
    By Uri Guttman in forum PERL Miscellaneous
    Replies: 0
    Last Post: July 3rd, 02:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139