Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 imbibing at the Monastery: (6)
As of 2015-07-04 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls