in reply to Re^2: searching for multiple strings in a line
in thread searching for multiple strings in a line

split will separate your input line based upon the input keyword (such as SELECT). If SELECT appears more than once in the line, then the @things array will have more than one element, and you will get your message output.
#!/usr/bin/perl use warnings; use strict; #This is where we read in the arguments from the command line my $file_name = shift; my $String = shift; #This is where we read in the file and output to the file open(INFILE, $file_name) or die "Can't open file\n"; #while reading from the file... while (<INFILE>) { $_ = uc(); my @things = split(/$String/); if ($#things > 0) { print "There is a nested SQL in this file\n"; exit; } }

Replies are listed 'Best First'.
Re^4: searching for multiple strings in a line
by dhudnall (Novice) on Jul 10, 2007 at 17:58 UTC
    Once again thank you toolic. The code above worked. I figured out why my code wasn't working as well but the code you have above it much cleaner. Thank you for your time.