autobox "endows Perl's core datatypes with the capabilities of first-class objects".
This is best demonstrated with an example:
#!/usr/bin/perl5.8.1-autobox -w use autobox SCALAR => 'Print'; package Print; sub print {print $_[0], "\n"}; 1; "Just Another Perl Hacker"->print(); __END__
And when you run it:
$ ./autobox.pl It's Perl Jim, but not as we know it.
Or (perhaps) the first autobox JAPH (with the above Print in a separate package):
perl5.8.1-autobox -Mautobox="SCALAR,Print" -MPrint -e '"Just Anoth +er Perl Hacker"->print()'
Or consider the following example from the pod:
Let the holy wars commence.my $schwartzian = [ @_ ]->map(...)->sort(...)->map(...);
--
John.
Back to
Perl News