Perl Character Meanings

This page explains a little about perl pattern matching and some of the options.

Pattern Matching

  • ~ - Used to identify a string to be looked for in the pattern.
  • !~ - The oposite of the ~ operator used to determine if a pattern does not match.
  • / - Used to delimit the pattern to be matched. An example is: /Pattern/

Pattern matching options

  • i - "Do case-insensitive pattern matching"
  • m - "Treat string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string. "
  • s - "Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which normally it would not match. The /s and /m modifiers both override the $* setting. That is, no matter what $* contains, /s without /m will force "^" to match only at the beginning of the string and "$" to match only at the end (or just before a newline at the end) of the string. Together, as /ms, they let the "." match any character whatsoever, while yet allowing "^" and "$" to match, respectively, just after and just before newlines within the string."
  • x - "Extend your pattern's legibility by permitting whitespace and comments. "
  • \b - "Match a word boundary "
  • \B - "Match a non-(word boundary) "
  • \A - "Match only at beginning of string "
  • \Z - "Match only at end of string, or before newline at the end "
  • \z - "Match only at end of string "
  • \G - "Match only at pos() (e.g. at the end-of-match position of prior m//g)"