Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: string/array smart match regex failing me

by oko1 (Deacon)
on Jan 05, 2011 at 21:14 UTC ( [id://880679]=note: print w/replies, xml ) Need Help??


in reply to string/array smart match regex failing me

JavaFan nailed it, but here's a way to do what you want:

#!/usr/bin/perl -w use strict; use 5.010; my $string = q(foo); map { say "$_: ", $string =~ /$_/i?"Matched":"No match" } qw( foo ba(r +|z) quux );

Update: Added the 'Matched/No match' bits.

-- 
Education is not the filling of a pail, but the lighting of a fire.
 -- W. B. Yeats

Log In?
Username:
Password:

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

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

    No recent polls found