I appreciate all the advice and examples to manipulate hash, hash table, code improvement and will do all of these with your help.
should I create a new thread for each example or stick with this thread? maybe some other newbie can learn from it.
Ok, I've been playing with hash ref to get a 2 element hash.
hasn't worked yet. will you provide some instruction/teach/explain the error I did on hash ref? error it gave me.
Can't use string ("dos") as an ARRAY ref while "strict refs" in use at C:\Users\Alberto\Documents\NetBeansProjects\PerlProject\Perl Essentials\hash_ref_6_4.pl line 34, <$in1> line 1.
use strict; use warnings; use Data::Dump qw(dump); my %hash; #my file handles UNTIL I figure how to install the Inline::File module + to netbeans IDE open my $in, '<',"./test_data.txt" or die ("can't open the file:$!\n") +; open my $in1,'<',"./test_data1.txt" or die ("can't open file : $!\n"); open my $out ,'>' ,"./test_data_out.txt" or die "can't open the file f +or write:$!\n"; open my $out1 ,'>',"./test_data_out1_no_match.txt" or die "can't open +file for write:$!\n"; #creating hash while (<$in>){ chomp; my ($key,$value)= split(/\s*=\s*/); #conto di spazio prima o dopo +la parola $hash{$key}=$value; } close $in; #using the first hash while (<$in1>){ chomp; my($key,$value)=split/\s*=\s*/ ; #push the value to existing hash as to get reference if key exists # %hash =( It => [Spa Fre]) #using one hash as per Ken code suggestion?? push @{$hash{$key}},$value if $hash{$key}; #non so come funzio +na "push" print $out dump (\%hash); } close $in1; close $out; close $out1;
In reply to Re^2: Need advice on checking two hashes values and keys
by perlynewby
in thread Need advice on checking two hashes values and keys
by perlynewby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |