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).


In reply to Re: Override "null filehandle" by haukex
in thread Override "null filehandle" by BillKSmith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.