Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the -m switch work in Perl

Tags:

perl

If you could explain the flow and how/why we can create a module to run with -Mm it will be helpful

like image 725
R.D Avatar asked Sep 05 '10 00:09

R.D


People also ask

What does $_ mean in Perl?

The most commonly used special variable is $_, which contains the default input and pattern-searching string. For example, in the following lines − #!/usr/bin/perl foreach ('hickory','dickory','doc') { print $_; print "\n"; }

What is the syntax of switch?

The syntax of the switch statement is:statement(s); break; case constant 2: statement(s);


1 Answers

-Mfoo simply generates the code use foo; and places it at the beginning of the code to be compiled.

-mfoo generates use foo ();

-Mfoo=bar,baz generates use foo ('bar','baz'); and so does -mfoo=bar,baz -- that is, there stops being a difference between -M and -m when you use the form with an equal sign, but without it, -m generates the "non-import" form of use.

This is all documented in perlrun.

like image 192
hobbs Avatar answered Oct 12 '22 07:10

hobbs