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

Re^2: How to check whether my array contains element x

by MidLifeXis (Prior)
on Jan 17, 2013 at 13:33 UTC ( #1013781=note: print w/ replies, xml ) Need Help??


in reply to Re: How to check whether my array contains element x
in thread How to check whether my array contains element x

You might want to change /^$value$/ to /^\Q$value\E$/, especially if $value may contain re metacharacters, but it depends on the application.

while (<>) { chomp; print qr(^$_$), "\t", qr(^\Q$_\E$), "\n"; } __END__ foo (?-xism:^foo$) (?-xism:^foo$) foo[bar] (?-xism:^foo[bar]$) (?-xism:^foo\[bar\]$)

--MidLifeXis


Comment on Re^2: How to check whether my array contains element x
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-09-23 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (239 votes), past polls