I want to enable say
feature (but also all the others). I know that if I write the code on the command line, I can use -E
option instead of -e
. But if I am running a script:
perl script.pl
I cannot use -E
. I don't want to put use feature say
in the script; I want to use command line option. What kind of option can I use here? I have not been able to figure this out from the documentation.
You can import a module with the -M
switch. In general,
-MFoo=bar,baz
is equivalent to
use Foo (split /,/ 'bar,baz');
So here, we would do -Mfeature=say
or load a feature bundle like -M5.010
.
However, I'd recommend specifying any features you use inside the script itself. This will avoid confusing errors when you forget to specify the switch.
I made a bash alias:
alias sperl='perl -Mfeature=say'
now I can do stuff like
~/perl$ sperl -e "say 'hi'"
hi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With