Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

RE: Code Explaining

by jlistf (Monk)
on Aug 09, 2000 at 19:23 UTC ( [id://27063]=note: print w/replies, xml ) Need Help??


in reply to Code Explaining

(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:
$_ =~ m/is is/ # or $_ =~ m/(is) \1/
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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://27063]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-25 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found