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...
|