Syntactic Confectionery Delight | |
PerlMonks |
RE: Code Explainingby jlistf (Monk) |
on Aug 09, 2000 at 19:23 UTC ( [id://27063]=note: print w/replies, xml ) | Need Help?? |
(simplified to some extent) the two /'s specify the matching operator (also seen as m//). this match operator allows you to search for certain regular expressions in a string. in this case, you are searching for 'is' which gets captured by the parentheses. this means that 'is' gets stored in the \1 variable. so you are searching for 'is' then a single space, then another 'is'. so where are you searching? well, the matching operator defaults to the $_ special variable (doesn't everything?). so you are looking in $_ for 'is is'. you can also specify a string to search in using the binding operator =~. so this expression could also be written as: the parentheses around the statement simply means that this is a test (for an if or a while or something). you should really check out the perlre manpage or 'Learning Perl' by O'Reilly or something for a much more detailed explanation of regular expressions. jeff
In Section
Seekers of Perl Wisdom
|
|