The problem is that the first argument of open should either be a filehandle, or a reference to a filehandle. Since 5.6, open will autovivify an undefined value into a filehandle (most people say "since 5.6, we have lexical filehandles". That's not true. Neither is the first argument of open a filehandle in this case, nor is 5.6 a requirement to have a lexical reference to a filehandle. Both have been possible long before 5.6 - it's only the autovivification that's new). But you're passing in a variable with a defined value; that's fine, Perl will try to use it as a reference to a filehandle. And the
*1 typeglob does have a slot for filehandles. It will all work fine and dandy, except that by enabling
strict 'refs', you're explicitely forbidden Perl to do its utter best to satisfy your request.
If you'd just replace $filehandle=$val; with my $filehandle;, it should all work.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.