in reply to Help with Perl RE

The syntax

$line =~ //

is short hand for

$line =~ m//

and checks if the contents of variable $line match the pattern surrounded by the //. Details on regular expressions can be found in the documentation in Perl regular expressions, quick reference guide, and tutorial. The pattern to be matched is

^([^{};]+[{};])(\s*\S+.*)$

and uses the s modifier, which tells the regex engine to treat the whole string as 1 line. The pattern does the following, in order:

  1. ^Start at the start of the string
  2. [^{};]+Match at least 1 of the characters other than {,} and ; (^ is not)
  3. [{};]Match exactly 1 of the characters {,} and ;
  4. \s*Match any amount of whites space (including none)
  5. \S+Match at least one non-white space character
  6. .*Match any number of any character
  7. $Stop at the end of the string

([^{};]+[{};]) also stores the punctuation in the variable $1 and (\s*\S+.*) stores the rest of the string in $2. If the string matches, then the conditional is true and the if block is executed.

Update: Cleaned up the above and put it in list form.

Update 2: I'm an idiot. When inside [], a carat means not. Thanks, cdarke.