in reply to Printing hash key shows obscure values - can this be trimmed/removed?

My guess is that you should replace

$hRec{$CmpKey,";",$CmpKey2}=$CmpValue;

with

$hRec{$CmpKey.";".$CmpKey2}=$CmpValue;

reason being that if you supply a list as a hash key, Perl uses $; as a seperator which has \034 as default value, see perlvar.

Replies are listed 'Best First'.
Re^2: Printing hash key shows obscure values - can this be trimmed/removed?
by AnomalousMonk (Archbishop) on Apr 28, 2015 at 13:27 UTC

    ... and octal \034 is a control-backslash or "^\" character.


    Give a man a fish:  <%-(-(-(-<

Re^2: Printing hash key shows obscure values - can this be trimmed/removed?
by yasmarina (Initiate) on Apr 28, 2015 at 13:27 UTC
    $hRec{$CmpKey.";".$CmpKey2}=$CmpValue;
    That works. Thank you. Any suggestion to avoid using UNIX system call 'egrep' to extract those records which do not match? i.e:
    my ($recnos, $vINVOICE_TXT) = split (';', $key) ; .... .... .... my $Rec=`egrep ^$recnos"\t"\$recnos.*$vInv $ARGV[0]` ;
    Once the differences have been identified, I split the key into 2 variables. Then attempt to grep the record from the input file to display the full record.

      egrep has a -v flag...

        Am looking to read into 2 tab-delimited files. Build a key and compare values. Those differences are output. I'd like to know an easier way to print the entire record of the differences as opposed to using UNIX grep via the key.
      Sure, Perl's grep built-in function is very powerful, in fact generally much more powerful than Unix' egrep (to tell the truth, they are not used exactly the same way, Perl's grep works on a Perl array, not exactly the same thing as Unix's egrep working usually on files or data flow), in part because Perl's regexes are incredibly good (and far beyond the "official" definition of regular expressions).

      In your case, I am fairly sure that Perl's grep function should do what you want much more efficiently than a system call to egrep, but I am not very clear on what you are really trying to achieve, so I can't help further for the time being. Please specify what you need.

      Je suis Charlie.