I am having a file
file.txt
january
february
egypt
moon
saturday
I want to search for each of these elements and report if any of them is missing.
I can do it by
open(FH,"file.txt");
@arr=<FH>;
$var=join("",@arr);
if($var=~ /january/)
{
print "january\n";
}
else
{
print "january not present\n";
}
if($var=~/february/)
{
print "february\n";
}
else
{
print "february not present\n";
}
if($var=~/egypt/)
{
print "Egypt is present";
}
else
{
print "Egypt not present";
}
etc...........
How can I reduce the code size and I should be able to report if any element is missing??????
One more doubt.....
If one of the element is to search is a regex like
a.*e
<sample>(.*?)</sample>
etc
How can I include those values in the search and maintain the properties of pattern matching???