The
-e
option is handy for quick Perl operations
from the command line. Want to change all instances of "oldstring" in
Wiffle.bat to "newstrong"? Try
perl -i.old -p -e "s/ oldstring/ newstrong/g" wiffle.bat
This says: "Take each line of Wiffle.bat (-p); store the original in Wiffle.old (-i); substitute all instances of oldstring with newstrong (-e); write the result (-p) to the
original file (-i)."
Other PERL command line options are:
Perl 5 Command-Line Switches
| Option | Arguments | Purpose | Notes |
| -0 | octal character code | Specify record separator | Default is newline ( /n ) |
| -a | none | Automatically spli recordst | Used with -n or or -p |
| -c | none | Check syntax only | Do not execute |
| -d | none | Run script using Perl debugger | If Perl debugging option was included when Perl was installed |
| -D | flags | Specify debugging behavior | See table 2 |
| -e | command | Pass a command to Perl from the command line | Useful for quick operations |
| -F | regular expression | If -a used | Expression to split by default is white space |
| -i | extension | Replace original file with results | Useful for modifying contents of files |
| -I | directory | Specify location of include files | |
| -l | octal character code | Drop newlines when used |
With
-n
and
-p
and use designated character as
line- termination character |
| -n | none | Process the script using each specified file as an argument | Used for performing the same set of actions on a set of files |
| -p | none | Same as -n but each line is printed | |
| -P | none | Run the script through the C preprocessor before Perl compiles it | |
| -s | none | Enable passing of arbitrary switches to Perl |
Use
-s -what -ever
to have the Perl variables
$what
and $ever defined within your script |
| -S | none | Tell Perl to look along the path for the script | |
| -T | none |
Use taint checking; don't evaluate expressions supplied on the
command line |
|
| -u | none |
Make Perl dump core after compiling your script; intended to allow
for generation of Perl executables |
Very messy; wait for the Perl compiler |
| -U | none | Unsafe mode; overrides Perl's natural caution | Don't use this! |
| -v | none | Print Perl version number | |
| -w | none | Print warnings about script syntax | Extremely useful, especially during development |