I'm not sure, but I think it works along the same lines as $_, a scalar that's filled with the line as the while loop iterates over the file. This is just an assumption, but I think you can't stuff into an array or hash slice.

If you put the following into your code:

print *MF; print "\n"; print $opt{'M'};

you'll see that the variables have the same content (unless there's some metadata controlling that), so it appears that the filehandle is being copied into the hash. I think your problem lies in the while loop, but I'm not sure yet why that is.

Update: from perlsyn:

The while and until modifiers have the usual "while loop" semantics (conditional evaluated first), except when applied to a do-BLOCK (or to the deprecated do-SUBROUTINE statement), in which case the block executes once before the conditional is evaluated.

The while is evaluating whether or not the hash or array has something in it. It's not evaluating the fileglob inside.

John J Reiser
newrisedesigns.com


In reply to Re: (nrd) hashs and file handle globs by newrisedesigns
in thread hashs and file handle globs by jroberts

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.