not knowing what "\*STDIN" represents

This may be more confusing than helpful. The short answer is that \*STDIN is the syntax required to pass a reference to the STDIN file handle to a subroutine (or object method).

Symbol tables in Perl are special hashes where the keys are the names of the symbols and the values are references to special data structures called typeglobs. A typeglob contains or has links to the state of all the variables with the given name. You may already know that you can have $var, @var and %var - three different variables all with the same name. There is one symbol table entry for all three of these: the key is 'var' and the value is a typeglob.

One of the types of values in a typeglob is a file handle. When you use something like $x = <STDIN>;, perl looks up 'STDIN' in the symbol table (a hash) and then uses the file handle of the referenced typeglob.

Since there is no 'sigil' (the '$', '@' and '%' in front of scalar, array and hash variable names are called sigils) for a file handle, so it is difficult to refer to one directly. One way to pass a file handle to a subroutine is to pass a reference to the entire typeglob that contains the file handle. \*STDIN is such a reference. The subroutine can use the reference to the typeglob to access the file handle.

You can read more about typeglobs in perldata and perlsub.


In reply to Re: MIME::Parser tries but fails to save files by ig
in thread MIME::Parser tries but fails to save files by Squiddy

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.