Lancy has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pattern Match is not working
by GrandFather (Saint) on Sep 07, 2011 at 11:14 UTC | |
by Lancy (Initiate) on Sep 07, 2011 at 12:38 UTC | |
| |
|
Re: Pattern Match is not working
by ww (Archbishop) on Sep 07, 2011 at 11:04 UTC | |
|
Re: Pattern Match is not working
by Perlbotics (Archbishop) on Sep 07, 2011 at 11:01 UTC | |
|
Re: Pattern Match is not working
by RichardK (Parson) on Sep 07, 2011 at 10:58 UTC | |
by Lancy (Initiate) on Sep 07, 2011 at 11:25 UTC |