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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.