Konstantin S. Uvarin writes: > I've come up with idea or a module that shortens (mostly test) > one-liners. > > perl -we 'use My::Very::Long::Module; $x = My::Very::Long::Module->new( foo > => 42 ); print $x->foo;' > > perl -Mnew=x=My::Very::Long::Module,foo,42 -we "print $x->foo;"
Have you seen Class::Autouse? You can do: perl -MClass::Autouse=:superloader -we '$x = My::Very::Long::Module->new( foo => 42 ); print $x->foo' You still have to type ->new, but don't need to repeat the module name. > However, I'm still unsure if the fun is worth putting into global > namespace, and module name HAS to be short, otherwise it kills the > idea. It only has to be short if you expect it to be typed by hand. I have ~/bin/1perl defined as: #! /bin/sh perl -w -MClass::Autouse=:superloader "$@" Then for a one-liner where I want classes to load themselves, I use 1perl (which I can type as 1 Tab) rather than perl: 1perl -e '$x = My::Very::Long::Module->new( foo => 42 ); print $x->foo' Could you do something similar? That is, give your module a meaningful — and therefore longer — name, and include in your distribution a script which uses it (similarly to how the Image::Size module comes with the imgsize program). Then when you want a quick one-liner that creates objects like this, use that script in place of perl. Smylers -- http://twitter.com/Smylers2