Module::Quote - a quote-like operator that requires modules for you
use Test::More tests => 1; use Module::Quote; my $number = qm( Math::BigInt 1.00 )->new(42); isa_ok $number, "Math::BigInt";
The qm() quote-like operator will load a module and return its name. So the following should just work, even if you haven't used Math::BigInt in advance.
qm()
use
qm( Math::BigInt 1.00 )->new(42)
The more usual invocation:
Math::BigInt->new(42)
won't automatically load Math::BigInt, won't check a version number, and crucially is ambiguous! (See what happens when you define a sub called BigInt in the Math package.)
BigInt
Math
The qm operator interpolates variables, so this works too:
qm
my $x = "BigInt 1.00"; qm( Math::$x )->new(42);
You may export qm with an alternative name:
use Module::Quote 'qmod';
You may provide a hashref of options for the quote-like operator:
use Module::Quote qm => { emulate => 'q' };
You can export the operator multiple times with different options:
use Module::Quote qm => { emulate => 'q' }, qqm => { emulate => 'qq' }, ;
The optimistic and prefix options from Module::Hash are supported. As is emulate which can be set to "qq" (the default) or "q" (to disable interpolation).
optimistic
prefix
emulate
"qq"
"q"
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Module-Quote.
Module::Hash - similar idea, but less magic.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Module::Quote, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Quote
CPAN shell
perl -MCPAN -e shell install Module::Quote
For more information on module installation, please visit the detailed CPAN module installation guide.