Perl flags -pe, -pi, -p, -w, -d, -i, -t?

Yes, Google is notoriously difficult for looking up punctuation and, unfortunately, Perl does seem to be mostly made up of punctuation 🙂

The command line switches are all detailed in perlrun (available from the command line by calling perldoc perlrun). Going into the options briefly, one-by-one:

  • -p: Places a printing loop around your command so that it acts on each line of standard input. Used mostly so Perl can beat the pants off Awk in terms of power AND simplicity 🙂
  • -n: Places a non-printing loop around your command.
  • -e: Allows you to provide the program as an argument rather than in a file. You don’t want to have to create a script file for every little Perl one-liner.
  • -i: Modifies your input file in-place (making a backup of the original). Handy to modify files without the {copy, delete-original, rename} process.
  • -w: Activates some warnings. Any good Perl coder will use this.
  • -d: Runs under the Perl debugger. For debugging your Perl code, obviously.
  • -t: Treats certain “tainted” (dubious) code as warnings (proper taint mode will error on this dubious code). Used to beef up Perl security, especially when running code for other users, such as setuid scripts or web stuff.

Leave a Comment