I'm sorry, but I don't quite understand what your real goal is here. Do you intend to open the output file only if the perl version is > 5.007, otherwise don't open the output file?

If so, I'm not sure that the benefit of using a lexically scoped file handle is worth the hassle if the code still has to run on older perl versions. Do you have some compelling reason for needing to use a lexically scoped file handle?

OTOH, if the goal is "open the file this way if perl is > 5.007 and open it the old way otherwise", that would be a really bad idea, because then you'd have to check the version and use eval every time you write to the file handle. Don't do that.

UPDATE: Apologies again... I just noticed this bit:

(Changing the open call to a 2 argument form is not a viable solution :-)

This seems to answer my first question -- no way you would want to open the file if running under an older version (which does not support 3-arg open). Perhaps you could elaborate on why a 2-arg open is not viable, and how that relates to the need to run under older versions of perl.

last update: D'oh!! why didn't I notice "\$var" the first time?! Still, I'm curious why you would add this in a script that is supposed to run under older versions...


In reply to Re: Compile time problem by graff
in thread Compile time problem by syphilis

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.