perl - Empty value on hash when key comes from a list -
i'm close me crazy.
i have array seems ok. array contains filenames (as keys) , total path on values of array. checked it's working.. here ok. here code:
open (file, "comb_d.txt"); @l = <file>; foreach $line (@l) { chomp($line); @linea = split(/separator/,$line); $hash_d{$linea[0]} = $linea[1]; } as said.. works, because verified that:
foreach $llave (keys %hash_o) { print "$llave = $hash_o{$llave}\n"; } and gives me total hash without issues..
here comes problem. don't want utilize filenames (all keys) on array, set of them. actually, there set of keys stored on @isect. when run:
foreach $llave ( @isect ) { print "$llave = $hash_o{$llave}\n"; } my result is:
filename1 = filename2 = i'm pretty sure elements on @isect exist keys of %hash_o.
help please
thanks!!
for this, data::dumper friend.
use data::dumper qw<dumper>; ... $hash_d{$linea[0]} = $linea[1]; dumper( \%hash_d ); } and later:
say dumper( \@isect ); dumper( \%hash_o ); you're spending lot of time doing data::dumper lite snack. , each effort @ trying this, because it's perl code , because may not speed perl, you're spending time debugging debug code, instead of getting solution done.
note: dumping not acceptable replacement reading api of object, in object-oriented perl, explain here. unblessed hashes (see bless or perlobj), it's structured info want know how at--it's way go.
finally, here's mention favorite tool smart::comments. this:
use smart::comments; ... ### %hash_d ### @isect ### %hash_o and watch magic.
perl hash
No comments:
Post a Comment