Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: grep {CONSTANT} @list

by frozenwithjoy (Curate)
on Nov 21, 2012 at 19:52 UTC ( #1004997=note: print w/ replies, xml ) Need Help??


in reply to grep {CONSTANT} @list

The way I see it, you still need to put // around the pattern you are trying to match that is contained in REGEX (in this case it is (?^:string)).

say grep { REGEX } @list; #doesn't work, because it isn't really doing what you think it is doin +g say grep { /REGEX/ } @list; #doesn't work because of the problems mentioned above when using const +ants in contexts that auto-quote barewords say grep { /(?^:string)/ } @list; #this works (and throws errors if // are removed) use Readonly; Readonly::Scalar my $regex_ro => qr/string/; say grep {/$regex_ro/} @list; #this works (and, as expected, gives same bad result you got if // is +removed) my $regex = qr/string/; say grep { /$regex/ } @list; #this works (and, as expected, gives same bad result you got if // is +removed)


Comment on Re: grep {CONSTANT} @list
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-11-26 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (173 votes), past polls