use strict;
use warnings;
while (<DATA>) {
chomp;
my $matched = /\<hell/ ? 'yes' : 'no';
print "/\\<hell/ matches '$_'? $matched\n"
}
__DATA__
shell
hell
this is hell
this is hellish
this is <hell
this is <hellish
some shells are bad
When run, this prints
Q:\>perl -w tmp.pl
'shell' matches? no
'hell' matches? no
'this is hell' matches? no
'this is hellish' matches? no
'this is <hell' matches? yes
'this is <hellish' matches? yes
'some shells are bad' matches? no
Please read perlre before making such claims. |