#!/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; my $CharPos = 0; my $TheLine = 0; my $LineLen = 0; my $counter = 0; #my $nestedSelects = false; #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() { #make all lowercase characters uppercase tr/a-z/A-Z/; #Save the line's contents $TheLine = $_; #may need to convert the line to a list??? HERE #Gets the length of the line $LineLen = length($TheLine); #until we reach the end of the line until($CharPos == $LineLen) { while($counter!=2) { #for every element in the line foreach $x ($TheLine) { #if the string equals any of the elements in the line if($String eq $x) { #add one to the counter $counter++; }#end if }#end of the for statement #if two of the same words were found in the sentence (ne sted selects) if($counter >=2) { print "There is a nested SQL in this file\n"; #nestedSelects = true; exit; }#end if else { $CharPos = $CharPos +1; } }#end of second while loop }#end of the until #sets the counter back to 0 for the next line $counter=0; }#end of the first while