in reply to option control in script

Yes, almost every option on the command line translates to Perl code that you can use in your script. This is covered almost entirely in perlrun (see this for the -i switch). Corion showed how to use B::Deparse, but note that the code it shows is often a little longer than it needs to be. For example, perl -lane 'print $F[2]' can be written like the following. I've added warnings and strict, and used my @F instead of our @F and local $\ to limit their scope.

use warnings; use strict; local $\ = "\n"; # -l while (<>) { # -n chomp; # -l my @F = split; # -a print $F[2]; # -e }

Also note that Perl parses command-line options on the shebang line. So for example, to get the effect of -s (rudimentary command-line switches) without having to specify it on the command line:

$ cat s.pl #!/usr/bin/perl -s use warnings; use strict; our $x; print "<$x>\n"; $ ./s.pl -x=foo <foo>

Replies are listed 'Best First'.
Re^2: option control in script
by BillKSmith (Monsignor) on Jul 22, 2018 at 20:42 UTC
    Under Windows, you normally do not have a shebang line. You can add one to specify run-time switches. It has no other effect.
    Bill
      It has no other effect.

      I know I'm nitpicking, but for example, Apache will read it (ScriptInterpreterSource), and I'm going to take a guess that Cygwin might do so too.