#!/usr/bin/perl -w
use strict;
foreach ("WORDHERE", "stuffthenWORDHERE", "WORDHEREthenstuff",
"stuffbeforeWORDHEREstuffafter", "wordhere", "no_word_here")
{
print "$_: ";
if($_ =~ /WORDHERE/gi)
{
print "matches";
}
else
{
print "doesn't match";
}
print "\n";
}
produces
WORDHERE: matches
stuffthenWORDHERE: matches
WORDHEREthenstuff: matches
stuffbeforeWORDHEREstuffafter: matches
wordhere: matches
no_word_here: doesn't match
|