Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: can any reply out with a better code than this??

by ysth (Canon)
on Dec 06, 2007 at 07:27 UTC ( [id://655295]=note: print w/replies, xml ) Need Help??


in reply to can any reply out with a better code than this??

Better in what sense?

If the string may contain characters special to a regex that you want treated as regular characters to match, do /(\Q$string\E){3}/.

Make the match non-capturing, since you are unlikely to be using the captured result: /(?:\Q$string\E){3}/.

If the "3" is always the same and for some reason it isn't fast enough, try repeating it: /\Q$string$string$string\E/.

Save the regex in a variable and reuse it: my $regex = qr/\Q$string$string$string\E/; ... if ($line =~ $regex) ....

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-20 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found