++ed by:
Father Chrysostomos

NAME

Classic::Perl - Selectively reinstate deleted Perl features

VERSION

Version 0.05

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

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 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.

ENABLING FEATURES

To enable all features, simply use use Classic::Perl;. To disable whatever Classic::Perl enabled, write 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 use or no:

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

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

THE FEATURES THEMSELVES

$[

This feature provides the $[ 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 $[ 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 removed, Classic::Perl will continue to provide it.

split

This features provides split to @_ in void and scalar context.

This was removed from perl in 5.11.

$*

This feature provides the $* variable, which, when set to an integer other than zero, puts an implicit /m on every regular expression.

Unlike the $* variable in perl 5.8 and earlier, this only works at compile-time and is lexically scoped (like $[ in 5.10-5.14). It only works with constant values. $* = $val does not work.

<$*> was removed in perl 5.9.

BUGS

Please report any bugs you find via http://rt.cpan.org or bug-Classic-Perl@rt.cpan.org.

ACKNOWLEDGEMENTS

Much of the structural code in the XS file was stolen from Vincent Pit's autovivification module and tweaked. The ptable.h file was taken straight from his module without modifications. (I have been subsequently informed that he stole it from B::Hooks::OP::Check, which pilfered it from autobox, which filched it from perl. :-)

Andrew Main (Zefram) added support for $[ in 5.16.

SINE QUIBUS NON

perl 5 or higher

In Perl 5.16 and higher, Array::Base and String::Base are required.

COPYRIGHT

Copyright (C) 2010-12 Father Chrysostomos

  use Classic'Perl;
  split / /, 'org . cpan @ sprout';
  print reverse "\n", @_;

This program is free software; you may redistribute it, modify it or both under the same terms as perl.

SEE ALSO

Array::Base, String:Base, perl, split in perlfunc, $* in perlvar, $[ in perlvar|perlvar/$[

any::feature is an experimental module that backports new Perl features to older versions.

The Modern::Perl module enables various pragmata which are currently popular.




Hosting generously
sponsored by Bytemark