Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash of arrays
by GrandFather (Saint) on Oct 26, 2011 at 09:22 UTC | |
|
Re: hash of arrays
by i5513 (Pilgrim) on Oct 26, 2011 at 09:47 UTC | |
by Anonymous Monk on Oct 26, 2011 at 10:00 UTC | |
|
Re: hash of arrays
by spazm (Monk) on Oct 26, 2011 at 09:09 UTC | |
by Anonymous Monk on Oct 26, 2011 at 09:14 UTC | |
by Anonymous Monk on Oct 26, 2011 at 09:24 UTC | |
by spazm (Monk) on Oct 26, 2011 at 09:32 UTC | |
by Anonymous Monk on Oct 26, 2011 at 09:45 UTC | |
by spazm (Monk) on Oct 26, 2011 at 09:55 UTC | |
| |
|
Re: hash of arrays
by spazm (Monk) on Oct 26, 2011 at 09:07 UTC | |
|
Re: hash of arrays
by jethro (Monsignor) on Oct 26, 2011 at 09:14 UTC |