Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-16 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found