dhudnall has asked for the wisdom of the Perl Monks concerning the following question:
#The first thing I want to do is to be able to call the function from +the command line along with the name of the file to parse followed by + the keyword to isolate. $FileName=shift; $String=shift; #Then I would open the file to parse before going any further open(INFILE, $FileName) or die "Cant open the file\n"; #Then I think I should convert the file to a list to parse @file=<INFILE>; #Then I guess I would do something like the following #While reading in from the file while(<INFILE>) { #Save the contents of EACH line $TheLine = $_; #Then I would search through each element of the line foreach $x (@file) #or $TheLine { #Then I would check to see if the string entered on the command line e +xists in the line (which it always will because I will know which SQL +s e.g. delete, update, etc...I am searching for in the file) if(exists $TheLine{$String}) { #Then I want to delete (or replace) everything BEFORE the keyword $Str +ing with a blank.....basically meaning erase it. This is where I am a +bsolutely lost at because I don't know of a relatively easy way to do + this. I figured I would use the S// operator something like s/.*$String//g #Basically do something like that #This would leave only the String I was looking for FOLLOWED by the re +st of the line. }#end if
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: isolating strings
by toolic (Bishop) on Jun 28, 2007 at 15:57 UTC | |
by clinton (Priest) on Jun 28, 2007 at 16:28 UTC | |
by dhudnall (Novice) on Jun 28, 2007 at 17:12 UTC | |
|
Re: isolating strings
by ikegami (Patriarch) on Jun 28, 2007 at 15:30 UTC |