Switches
A single-character command-line switch without its own argument may always be combined (bundled) with a switch following it.
#!/usr/bin/perl –spi.bak # same as –s –p –i.bak
Switches are also known as options or flags. Whatever you call them, here are the ones Perl recognizes:
––Terminates switch processing, even if the next argument starts with a minus. It has no other effect.
- –0
DIGITS Specifies the input record separator (
$/) as an octal number or hexadecimal number representing that single character’s codepoint. If no digits are specified, the null character (that’s U+0000, Perl’s"\0") is the separator. Other switches may precede or follow the digits. For example, if you have a version of find(1) that can print filenames terminated by the null character, you can say this to delete a bunch of them:% find . –name '*.bak' –print0 | perl –n0e unlinkThe special value
00makes Perl read files in paragraph mode, equivalent to setting the$/variable to"". Any value0400or above makes Perl slurp in whole files at once, but, by convention, the value0777is normally used for this. This is equivalent to undefining the$/variable. We use0777since there is no ASCII character with that value. (Unfortunately, there is a Unicode character with that value, latin small letter o with stroke and acute, but something tells us you won’t be delimiting your records with that. But if you really want to, just specify its codepoint in hex: –0x1FF.)You can also specify the separator character ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access