Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: regex "o" modifier (use qr//)

by Aristotle (Chancellor)
on May 07, 2003 at 07:46 UTC ( [id://256140]=note: print w/replies, xml ) Need Help??


in reply to Re: regex "o" modifier
in thread regex "o" modifier

That's a perfect example of what qr// was made for.
for my $day_week( qw(Mon Tue Wed Thu Fri Sat Sun) ) { my $regexp = qr/^$day_week/; for my $day (qw (Mon Mon Wed Fri Sat Sun Fri Wed Tue Wed)) { if($day =~ m/$regexp/) { # do somthing } } }
Much clearer and more readable and, yes, more efficient too. tye is right: Never use /o.

Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found