Hi Monks I am new to Perl below is my script for comparing two text files and printing the difference. pattern matching is working for one occurrence. Could you please guide me where i am going wrong. Thanks for your kind help.
#!/usr/bin/perl #use strict; use warnings; open(FILE,'>C:\\Aolvldbcomp\\Difference.txt'); my ($names, $data) =('LEAP_O.txt','VLDB_O.txt'); open (FILE1,$names) || die; open (FILE2,$data) || die; my @leapStrings = <FILE1>; chomp (@leapStrings); close(FILE1); my @vldbStrings = <FILE2>; chomp (@vldbStrings); close(FILE2); for my $leapString (@leapStrings){ print FILE "$leapString"; $leapString =~ s/^\s+//; $leapString =~ s/\s+$//; my $found = 0; for my $vldbString (@vldbStrings){ $vldbString =~ s/^\s+//; $vldbString =~ s/\s+$//; $vldbString =~ s/Notification\s+(\d+)\s*$/N $1/g; $vldbString =~ s/Order/OR/g; if (($leapString) =~ m/$vldbString/i) { $found = 1; break; } } if ($found) { print FILE "\t FOUND IN VLDB =====\n"; } else { print FILE "\t NOT FOUND IN VLDB =====\n"; } } close(FILE);
In reply to Pattern Match is not working by Lancy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |