Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: match with exception

by davis (Vicar)
on May 19, 2009 at 12:57 UTC ( #764908=note: print w/ replies, xml ) Need Help??


in reply to match with exception

I'd be inclined to use the "does not match" feature of !~:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $string = "asdfxyzasdf"; print "Not found\n" if($string !~ /xyz/);
Of course, that assumes a regular expression is the best way of (not) matching your string -- if it's just a simple string, then the perl function index() may be more suitable.
Edit: Changed wording to more accurately reflect test.

davis


Comment on Re: match with exception
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2014-08-01 17:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (33 votes), past polls