If you want to use Perl 5.6.0isms and make sure that perl won't attempt to run the code with an earler version, you can always require version number; (see perlfunc's require entry for more information).

The problem with the code you've listed is that it uses a pragmatic module that isn't available in versions prior to 5.6.0. If someone tries to run this code with an earlier version, perl will try to locate and evaluate warnings.pm before it tries to evaluate the version requirement, and will tell you it "can't locate warnings.pm in @INC..." then die.

If you place the version requirement in a BEGIN block it will be evaluated before any attempt to find warnings.pm and perl will print a message explaining that at least 5.006 is required and then die.

# note that versions prior to 5.6.0 require the numeric # representation of the version number and don't recognize # v5.6.0 or 5.6.0, for example. BEGIN { require 5.006_00 }

Example:

$ perl553 -e 'BEGIN{require 5.006_00}; use warnings;' Perl 5.006 required--this is only version 5.00503, stopped at -e line +1. BEGIN failed--compilation aborted at -e line 1.

Update:

require happens at run-time, after compilation, while use happens at compile-time. This is why perl tries to use the pragmatic module warnings.pm before require version number; is evaluated.

Placing the require expression in a BEGIN block is one solution, but not the best. use module counts as a BEGIN block and is evaluated at compile-time, so the best solution here is probably:

use 5.006_00;


In reply to Re: All files in dir to Storable.pm data by converter
in thread All files in dir to Storable.pm data by deprecated

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.