What I said about keys applies to values and each as well. It's not a backward incompatible change, so no feature needs to be activated. Your code boils down to

use if $] < 5.012, 'Enumerators';

Prepending scripts with nine lines of code is not what I was hoping for.

That's because you're trying to write your code inside out. A less messy approach would be to include Enumerators unconditionally, and let it decide if it needs to override each or not. It's not a detail the module's user should worry about.

# use Enumerators -global; # use Enumerators qw( each ); # use Enumerators; package Enumerators; use Exporter qw( ); our @EXPORT = qw( each ); our @EXPORT_OK = qw( each ); sub import { my $class = shift; return if $[ >= 5.012; if ($_[0] eq '-global') { *CORE::GLOBAL::each = \&each; } else { goto &Exporter::import; } } sub each(\[@%]) { ... } 1;

(Trim out what you don't want.)

Note that this approach works for pragams too.

package stricter; sub import { require strict; strict->import; require warnings; warnings->import; } 1;

use stricter; does the same as use strict; use warnings;


In reply to Re^3: Howto "use" backward compability packages of new "feature"s by ikegami
in thread Howto "use" backward compability packages of new "feature"s by LanX

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.