Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 perusing the Monastery: (4)
As of 2014-10-25 02:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (140 votes), past polls