Hi davido,

Actually I stuck with some other work, so could not post whatever I tries so far. Pls find the below code. Actually, the requirement is to find the changed lines in the second file and check all those changes have proper tag. Tag is nothing but the ticket number. The use will make their changes within the first chracters of each line, after that other characters will have comment about the line(contains ticket number also).

use strict; use warnings; use Data::Dumper; use FileIO; # own module to do file operations my $old_file = shift; my $new_file = shift; my $tkt_no = shift; my @old_version; my @new_version; my $error; #reads the file into array if (not FileIO::read_file_strip($old_file,\@old_version,\$error)){ print $error; return; } if (not FileIO::read_file_strip($new_file,\@new_version,\$error)){ print $error; return; } my %second_file; foreach my $oline ( @old_version ){ my $oshort_line = substr( $oline, 0, 49 ); $second_file{unpack 'A*', $oshort_line} = $oline; } foreach my $nline (@new_version) { my $nshort_line = substr( $nline, 0, 49 ); if( not exists $second_file{unpack 'A*', $nshort_line}){ my $tmp_str = substr($nline,50,-1); if ( defined $tmp_str and $tmp_str ne ""){ if ( $tmp_str =~ /$tkt_no/){ print("Tag Valid for $nline\n"); } }else{ print("Tag not found for $nline\n"); } } }

All is well. I learn by answering your questions...

In reply to Re^2: Best way to compare range of characters in two text files by vinoth.ree
in thread Best way to compare range of characters in two text files by vinoth.ree

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.