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

Re^2: Referencing the null file handle, <>

by Haarg (Chaplain)
on Jun 06, 2008 at 04:40 UTC ( #690599=note: print w/ replies, xml ) Need Help??


in reply to Re: Referencing the null file handle, <>
in thread Referencing the null file handle, <>

Quoting from perlvar:

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.
So what you posted won't work. I don't know of any way reproduce the same function with a passed parameter, although I suspect a tied file handle would be the best way to do so.


Comment on Re^2: Referencing the null file handle, <>
Re^3: Referencing the null file handle, <>
by Porculus (Hermit) on Jun 06, 2008 at 21:44 UTC

    It works for me; that is, (on my particular systems with the particular versions of Perl I'm using,) passing \*ARGV to a (trivial) function that expects a filehandle certainly does cause it to read the contents of all the files in @ARGV, even if I have reassigned @ARGV since the last read from <>.

    So, I'm now intrigued by that "may not" there. What are the conditions where it doesn't work? Is it platform-based? version-based? phase-of-moon-based...?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-05 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls