Hi guys ,, I have two files , one contain data like this
data.txt hello.pl~45~warning~454~null pointer hello.pl~43~warning~454~memory hello.pl~4532~warning~454~badpointer hello.pl~22~warning~454~null pointer hello.pl~88~warning~454~null pointer
where the first number in each line indcating the line number. in my second file I have only line numbers that been changed , somthing like this
lineChanged.txt 22-33 90 42-44 100
where 22-33 indicating that line 22 to 33 have changed. so what I need to do is reading from the lineChanged.txt file each line and see if they appear in data.txt or they are in the range , if it does then I want to print that line from the data.txt and send it to a an output file , so in my example , my output will be
hello.pl~43~warning~454~memory hello.pl~22~warning~454~null pointer
since they appear in both files I am doing somthing like this right now but it is not doing the work
while (<CHANGES>) { chomp; # split the line from the spaces # $file is file name like hello.pl $info = $_; is it a range or a single line? if ($info =~ /(\d+)-(\d+)/) { $changes{$file} .= " ".join(" ",($1 .. $2))." "; } else { $changes{$file} .= " $info "; } if (defined $changes{$file}) { # was it a range? if (defined $changes{$file}->[1]) { # skip if this $line is not in this range next unless ($line gt $changes{$fill}->[0] and $line lt $change +s{$file}->[1]); } else { # skip if this $line is not equal to this single line number next unless $line eq $changes{$file}->[0]; } # if we are here, then this is a match. so print it. print "############ Here ################\n"; # print "$_\n"; #print "############ Here ################\n"; }
can someone tell me an easir way or tell me what is it wrong I am doing .. thanks for help

In reply to regex with comparing by DS

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.