Kentdn has asked for the wisdom of the Perl Monks concerning the following question:
print "Enter File name and path of .ins?"; $filename1 = <STDIN>; print "Enter the name of the .rcs file to be searched?"; $filename2 = <STDIN>; open( FILE, "< $filename1" ) or die( "can't find file1: $ +!" ); $/=undef; @file = <FILE>; close(FILE); print @file,\n; foreach $line (@file) { $line =~ /.*EditorName\b.*\b(.+?)\b/; $word1 = $1;} foreach $line2 (@file) { $line2 =~ /.*EditorCommand\s+'(\w+)'\s/; @word2 = $1;} print @word2, \n; open FILE, ">test54.txt" or die "Could not open file: $!\n"; open (Output, ">test54.txt"); foreach $word2 (@word2) { { $pattern = $word1.":".$word2; if (in_file($pattern, $filename2) ) { + print Output "Found $pattern in $filename2\n"; } else { print "$pattern not found in $filename2.\n"; } sub in_file { my ($pattern, $filename2) = @_; open FILE, $filename2 or die "Can't open $filename: $!\n +"; my $found =0; while (<FILE>) { $found=1, last if /$pattern/; } close FILE; $found; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help needed on a foreach loop from hell!!!
by VSarkiss (Monsignor) on Jan 24, 2002 at 05:52 UTC | |
by Kentdn (Novice) on Jan 25, 2002 at 03:04 UTC | |
|
Re: help needed on a foreach loop from hell!!!
by Ineffectual (Scribe) on Jan 24, 2002 at 05:10 UTC | |
by Kentdn (Novice) on Jan 24, 2002 at 05:21 UTC | |
by Ineffectual (Scribe) on Jan 24, 2002 at 06:24 UTC | |
by theguvnor (Chaplain) on Jan 24, 2002 at 07:10 UTC | |
by Ineffectual (Scribe) on Jan 24, 2002 at 22:54 UTC | |
by theorbtwo (Prior) on Jan 24, 2002 at 05:43 UTC |