How does this make the one liner shorter? Isn't '->' the same length as '-M'? If I wanted to use more than one exported function (or the same function more than once) from Foo::Bar wouldn't this actually make the 1 liner longer?
It depends on the module, if Foo::Bar exports a procedural
interface by default then it won't shorten anything.
If it optionally exports functions then you have to
type them in the export list (-MFoo::Bar=blah,asdf)
in addition to the code.
Dev::Bollocks doesn't export anything so you'd need to
repeat the module name:
I often use one liners like this to test drive a module,
sometimes to filter things (eg. with Email::Valid).
I expect that the -MSome::Long::Name -e '$s=Some::Long::Name->new()' type scripts will
BTW, I've only just started using this alias so I don't
have a much of feel for it yet...
perl -MXDG -e 'say "Loaded modules:" and Dump \%INC'
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.