Update: italics added to main point. Extraneous \ removed before single quotes.
use strict; use warnings; my @CPC_STP_type =('bus does not stop here','bus stop', 'anything', 'n +ot this stop'); foreach my $type (@CPC_STP_type) { if ($type =~ m/not stop/) #the "m" is optional { print "type=$type......'not stop' detected\n"; } else { print "type=$type......'not stop' was NOT detected\n"; } } print "\n"; =prints type=bus does not stop here......'not stop' detected type=bus stop......'not stop' was NOT detected type=anything......'not stop' was NOT detected type=not this stop......'not stop' was NOT detected =cut foreach my $type (@CPC_STP_type) { if ($type !~ m/not stop/) #the "m" is optional { print "type=$type......We stop here\n"; } else { print "type=$type......We keep going\n"; } } __END__ #watch out for the unexpected! type=bus does not stop here......We keep going type=bus stop......We stop here type=anything......We stop here type=not this stop......We stop here <= Whoa!!
In reply to Re: Forward slashes around argument
by Marshall
in thread Forward slashes around argument
by thnksnw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |