Hello, all;

I am debugging code written by someone else, and noticed the following:
===START=CODE===
sub getParameters {
   my $parm_list = do { local(@ARGV,$/); <> };
}
===END=CODE===

This does what the author expected (slurp STDIN into the scalar "$parm_list") 
but I was surprised by the "<>" as a stand-in for <STDIN> so I looked it up. 
Here is what I found:
   http://perldoc.perl.org/perlvar.html
===START=PASTE===
ARGV

The special filehandle that iterates over command-line filenames in @ARGV . 
Usually written as the null filehandle in the angle operator <> . Note that 
currently ARGV only has its magical effect within the <> operator; elsewhere it 
is just a plain filehandle corresponding to the last file opened by <> . In 
particular, passing \*ARGV as a parameter to a function that expects a 
filehandle may not cause your function to automatically read the contents of 
all the files in @ARGV .

$ARGV

contains the name of the current file when reading from <>.
===END=PASTE===

I could find no reference to "<>" as a synonym for "<STDIN>" ... am I missing 
something obvious? [The code works, so obviously it is my knowledge that is 
faulty.] If someone could point me at a reference or doc or faq, I'd be 
grateful.

Also, is there any particular reason (in the example given above) why '@ARGV' 
would need to be localized, or is the author just being overly cautous?

Thanks, in advance, for your input!

---
Stephen ~runester~ Jarjoura
http://runester.com
http://boston.pm.org/kwiki/index.cgi?StephenJarjoura

 
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to