How do you know what $_ really is in your program?

What you saw is the stringification, which is not necessarily the same thing. For instance:

my $x = \*FH; print "plain glob ref: <$x>\n"; # prints: plain glob ref: <GLOB(0x1d6c660)> open ($x, "<","somefile") or warn "error\n"; print "open FH ref: <$x>\n"; # prints: open FH ref: <GLOB(0x1d6c660)>
But if instead I use x to peek at the globref in the debugger, it looks like this:
my $x = \*FH; x $x # prints: #0 GLOB(0x1d6c408) # -> *main::FH open ($x, "<","somefile") or warn "error\n"; print "open FH ref: <$x>\n"; # prints: 0 GLOB(0x1d6c408) -> *main::FH FileHandle({*main::FH}) => fileno(6)
...which is much more interesting.

What do you get in your code?

-QM
--
Quantum Mechanics: The dreams stuff is made of


In reply to Re: Passing a file handle to a sub. I still don't get it. by QM
in thread Passing a file handle to a sub. I still don't get it. by rvosa

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.