Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: matching elements in a list in a logical OR fashion

by parv (Parson)
on Jun 15, 2004 at 04:37 UTC ( [id://366770]=note: print w/replies, xml ) Need Help??


in reply to matching elements in a list in a logical OR fashion

I have something like the following in one of my own modules ...

print match_one( "string" , [ qw/character word paragraph string/ ] ) ? "matched" : "no match" ; sub match_one { my ($string , $list) = @_; foreach ( @{$list} ) { return 1 if $string =~ m/$_/; } return; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-19 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found