Classic-Perl

 view release on metacpan or  search on metacpan

lib/Classic/Perl.pm

  delete $^H{"Classic_Perl__$_"};
 }
 return if @_;
# if($^H{'Classic_Perl__$['}) {
#  Array::Base->unimport;
#  String::Base->unimport;
# }
 if(exists $^H{'Classic_Perl__$*'} and $] > 5.0130069 and $INC{"re.pm"}) {
  unimport re:: "/m";
 }
 delete @^H{map "Classic_Perl__$_", keys %features};
 return;
}

BEGIN {
 $VERSION='0.07';
 if($]>5.0089999){
  require XSLoader;
  XSLoader::load(__PACKAGE__, $VERSION);
 }
}

package Classic::::Perl;

$INC{"Classic/Perl.pm"} = $INC{"Classic//Perl.pm"} = __FILE__;

sub VERSION {
 my @features;
 push @features, '$*'    if $_[1] < 5.0089999;
 push @features, 'split' if $_[1] < 5.0109999;
# push @features, '$['    if $_[1] < 5.0150029;
 Classic::Perl->import(@features) if @features;
}

__THE__=>__END__

=head1 NAME

Classic::Perl - Selectively reinstate deleted Perl features

=head1 VERSION

Version 0.07

=head1 SYNOPSIS

  use Classic::Perl;
  # or
  use Classic::Perl 'split';

  split //, "smat";
  print join " ", @_; # prints "s m a t"

  no Classic::Perl;
  @_ = ();
  split //, "smat";
  print join " ", @_;
    # prints "s m a t" in perl 5.10.x; nothing in 5.12

  use Classic::Perl '$[';
  $[ = 1;
  print qw(a b c d)[2]; # prints "b"

  use Classic::Perl '$*';
  $* = 1;
  print "yes\n" if "foo\nbar" =~ /^bar/; # prints yes

=head1 DESCRIPTION

Classic::Perl restores some Perl features that have been deleted in the
latest versions. By 'classic' we mean as of perl 5.8.x.

The whole idea is that you can put C<use Classic::Perl> at the top of an
old script or module (or a new one, if you like the features that are out
of vogue) and have it continue to work.

In versions of perl prior to 5.10, this module simply does nothing.

=head1 ENABLING FEATURES

To enable all features, simply use C<use Classic::Perl;>. To disable
whatever Classic::Perl enabled, write C<no Classic::Perl;>. These are
lexically-scoped, so:

  {
     use Classic::Perl;
     # ... features on here ...
  }
  # ... features off here ...

To enable or disable a specific set of features, pass them as arguments to
C<use> or C<no>:

  use Classic::Perl qw< $[ split $* >;

To enable features that still existed in a given version of perl, put
I<four> colons in your C<use> statement, followed by the perl version. Only
plain numbers (C<5.008>) are currently supported. Don't use v-strings
(C<v5.8.0>).

  use Classic::::Perl 5.016; # does nothing (yet)
  use Classic::::Perl 5.014; # enables $[, but not split or $*
  use Classic::::Perl 5.010; # enables $[ and split, but not $*
  use Classic::::Perl 5.008; # enables everything

This is not guaranteed to do anything reasonable if used with C<no>.

=head1 THE FEATURES THEMSELVES

=over

=item $[

This feature provides the C<$[> variable, which, when set to an integer
other than zero, offsets indices into arrays and strings.  For example,
setting it to 1 (almost the only non-zero value actually used) means
that the first element in an array has index 1 rather than the usual 0.
The index offset is lexically scoped, as C<$[> has been as of Perl 5.10,
unlike its behaviour in Perl 5.0-5.8 (file-scoped) and Perl 1-4 (global).

This is deprecated in Perl, but has not yet been removed.  If it is

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.477439 second using v1.00-cache-1.03-grep-7fa205e-cpan-6421e59f23b )