![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Help with Perl REby kennethk (Abbot) |
on Jan 22, 2009 at 16:16 UTC ( [id://738210]=note: print w/replies, xml ) | Need Help?? |
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:
([^{};]+[{};]) 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.
In Section
Seekers of Perl Wisdom
|
|