new - Object instantiation sugar for one-liners
Simplest possible usage:
perl -Mnew=HTTP::Tiny -E \ 'say $O->get("http://trout.me.uk/X11/vimrc")->{content}'
With arguments:
perl -Mnew=HTTP::Tiny,max_redirects,3 -E \ 'say $O->get("http://trout.me.uk/X11/vimrc")->{content}'
With custom object name:
perl -Mnew=HTTP::Tiny,\$H -E \ 'say $H->get("http://trout.me.uk/X11/vimrc")->{content}'
With both:
perl -Mnew=HTTP::Tiny,\$H,max_redirects,3 -E \ 'say $H->get("http://trout.me.uk/X11/vimrc")->{content}'
new->import($class, @args)
First we require the file for $class, then call
require
$class
$class->new(@args)
then install the resulting object in $O in the calling package.
$O
Caveat: if $class loads successfully but does not have a new method, we install the $class instead since you might want to call class methods.
new
If the first argument to import after $class begins with $, this is treated as the name to install the object as, so
import
$
new->import($class, '$Obj', @args);
will create a variable $Obj in the calling package instead of $O.
$Obj
mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
None yet - maybe this software is perfect! (ahahahahahahahahaha)
Copyright (c) 2020 the new "AUTHOR" and "CONTRIBUTORS" as listed above.
This library is free software and may be distributed under the same terms as perl itself.
To install new, copy and paste the appropriate command in to your terminal.
cpanm
cpanm new
CPAN shell
perl -MCPAN -e shell install new
For more information on module installation, please visit the detailed CPAN module installation guide.