in reply to Override "null filehandle"
in this case, the input from <> comes from "standard input". If this were exactly the same thing as "STDIN"
As per perlop and choroba's reply, <> is the same as <ARGV>.
Is there a way to override the "null filehandle" ?
That depends a bit on what you want to accomplish, could you describe that?* You've already gotten some replies on how to do this for a couple of cases, and I just wanted to add that messing with ARGV even more is possible, as I did in my module Tie::Handle::Argv. However, because of all of the trouble I had writing and testing that module, I can say that this is a pretty complicated thing to do, and I would not mess with <> if it can be avoided. Therefore your sample code makes me a bit nervous that you might be trying to do something that's not really advisable.
* So for example, if you just want to mock <> for testing, it's better to do that by calling your script from another script and feeding it stuff to its STDIN, which can be done reliably, or just by placing test files (e.g. generated via File::Temp) in its @ARGV (Update: for example, you can localize *ARGV - yes, the whole typeglob).
|
|---|