Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: @ARGV in while loop

by BrowserUk (Patriarch)
on Feb 14, 2014 at 17:38 UTC ( [id://1074982]=note: print w/replies, xml ) Need Help??


in reply to @ARGV in while loop

why the $ARGV[0] in while loop cannot be accessed?

Because the diamond operator (when used with the null filehandle <>) consumes the contents of @ARGV.

See the section of perlop I/O-Operators that starts with the sentence:

The null filehandle <> is special:
for the details.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: @ARGV in while loop
by lightoverhead (Pilgrim) on Feb 14, 2014 at 17:59 UTC

    Thank you BrowserUK. You are right. It's good to learn.

    what about this:

    for(;;){ print "3:\t$ARGV[0]\n"; #cannot print either last; }
    Is $ARGV[0] consumed too?

      my fault

      I put for(;;;) after while().

      if run for(;;) first, it will print $ARGV[0]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1074982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-03-29 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found