I've commented out
# my @RecLine=split (/;/) ; my @RecLine=split ('\t') ;
Here's the rest of the code:
my $Key=$NR ; my $Cmp=$CHARGE ; my $Key2=$INVOICE_TXT; sub Read_File { my $FILE = shift ; open (my $fh, "<", $FILE) || die "$!" ; my %hRec ; while (<$fh>) { chomp; #my @RecLine=split (/;/) ; my @RecLine=split ('\t') ; $CmpKey=$RecLine[$Key] ; $CmpKey2=$RecLine[$Key2] ; $CmpValue=$RecLine[$Cmp] ; $hRec{$CmpKey,";",$CmpKey2}=$CmpValue; } return (%hRec) ; } my %hBase=Read_File($ARGV[0]) ; my %hPost=Read_File($ARGV[1]) ; my $FILE_DATE=`date "+%Y%M%d_%H%M_%S"` ; chomp ($FILE_DATE) ; my $OUT_FILE="/tmp/CMP_OUT_$FILE_DATE.txt" ; open ( OFILE, "> $OUT_FILE" ) or die "FATAL ERROR! Unable to write fil +e(!)\n" ; ## Debug ## #chomp($key); #foreach my $key (sort {$a<=>$b} keys %hBase) { print "$key -> $hBase +{$key}\n"; } #foreach my $key (sort {$a<=>$b} keys %hPost) { print "$key -> $hPost +{$key}\n"; } foreach my $key (sort {$a<=>$b} keys %hPost) { $count=$count+1 ; if ($hBase{$key} ne $hPost{$key}) { #my $out_counter = "\n##Comparing _$ARGV[0] vs. $ARGV[1]_ differ +ences(!) in record: $count##\n" ; my ($recnos, $vINVOICE_TXT) = split (';', $key) ; chop ($recnos) ; $vINVOICE_TXT=~s!^.!!; my $vInv= "\"$vINVOICE_TXT\"" ; my $Rec=`egrep ^$recnos"\t"\$recnos.*$vInv $ARGV[0]` ; my $out_baseline = "\n$ARGV[0]:\n$HEADER\n$Rec" ; my $Rec=`egrep ^$recnos"\t"\$recnos.*$vInv $ARGV[1]` ; my $out_compare="\n$ARGV[1]:\n$HEADER\n$Rec" ; my $out_result="\n$ARGV[0] [$key -> $hBase{$key}] do not match(! +) with $ARGV[1] [$key -> $hPost{$key}] in record: $count\n" ; print OFILE "$out_result $out_baseline $out_compare " ; print "$out_result $out_baseline $out_compare " ; } } close ( $FILE ) ; close ( OFILE ) ;
Note that I've added bits to trim off the obscure values:
my ($recnos, $vINVOICE_TXT) = split (';', $key) ; chop ($recnos) ; $vINVOICE_TXT=~s!^.!!; my $vInv= "\"$vINVOICE_TXT\"" ;
Am hoping to find a better way... Second to that, I used UNIX 'egrep' to extract the record. Am hoping to find a better way using perl code. Thanks

In reply to Re^2: Printing hash key shows obscure values - can this be trimmed/removed? by yasmarina
in thread Printing hash key shows obscure values - can this be trimmed/removed? by yasmarina

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.