Now,foreach my $string ( @word ) { if ( $uword{ $string }[ 0 ] == 1 ) { push @{ $uword{ $string } }, $line; next; } $uword{ $string }[ 0 ] = 1; push @{ $uword{ $string } }, $line; } #this [0] is apparently not needed #maybe I'm missing something, but what do you think #that this does? #simplify to just... foreach my $string (@word) { push ( @{$uword{$string}}, $line ); }
You've got some pretty complex syntax and maybe if you explained a bit more, some major simplifications could be made.@{ $uword{ $seen{ $key }[ 1 ] } # there is no closing curly for the @ # its rather strange looking but # { $seen{ $key }[ 1 ] } is the key for the hash
You are adding an unnecessary complication with this [0] =1 or not stuff. It is not necessary.
is all you need. If $hash{$key} doesn't exist prior to the push, the key will be created automatically.push @{$hash{$key}}, $value;
In reply to Re: error joining hashref of an arrayref
by Marshall
in thread error joining hashref of an arrayref
by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |