On 20 Jun 2001 10:20:20 +0100, Wayne Bridgman wrote:
> Hi Beginners,
>
> Does anyone know how I can look for a certain phrase within a sql file
> (approx 6 words, normally part of a header)?
> Thanks in advance,
> Wayne
>
Well, that depends on what you mean by "look for" and "sql file". If
you mean tell me whether these six words are adjacent (except for white
space) to each other in this file then this will do it:
my $filename = "filename";
open FH, $filename or die "Could not open $filename:$!";
{ local ($/) = undef; my $file = <FH> }
close FH;
#\s = whitespace, + means one or more of the preceding character.
if ($file =~ /these\s+words\s+are\s+the\s+six\s+words/) {
print "Found it!\n";
} else {
print "Not in this file!\n";
}
--
Today is Sweetmorn, the 25th day of Confusion in the YOLD 3167
Hail Eris!