my code suppose to run and store all second column string to the array for each key of the first column.mv89psg6zh4 A bird in a sink keeps getting under the running water +from a faucet. mv89psg6zh4 A bird is bathing in a sink. mv89psg6zh4 A bird is splashing around under a running faucet. mv89psg6zh4 A bird is bathing in a sink. mv89psg6zh4 A bird is standing in a sink drinking water that is pou +ring out of the facet. mv89psg6zh4 A faucet is running while a bird stands in the sink bel +ow. mv89psg6zh4 A bird is playing in a sink with running water. mv89psg6zh4 A bird is playing in tap water. mv89psg6zh4 A bird is bathing in the sink. mv89psg6zh4 A bird is taking a bath.
I get in the output this:use strict; use warnings; use open IN => ':utf8'; use open OUT => ':utf8'; use Encode; my $file1 = shift; my (%hash,$key); open( IN1, "<:encoding(utf8)", $file1 ); while (<IN1>) { chomp; my ($video, $p) = split /\t/; chomp ($video, $p); push( @{$hash{$video}}, $p ); #print "array of hash of $video <==== $p\n"; } foreach $key ( keys %hash ) { print "$key: @{ $hash{$key} }\n" } close IN1;
Where is wrong in my code? I've tried many solutions but they did not work either! Thanks in advance.A bird is taking a bath. sink..h running water.sink below.g out of th +e facet.cet.
In reply to hash of arrays by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |