Hi dear Monks I'm so puzzled with a very stupid error that I cant figure it out. I have my data in a tab separated file as:
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.
my code suppose to run and store all second column string to the array for each key of the first column.
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;
I get in the output this:
A bird is taking a bath. sink..h running water.sink below.g out of th +e facet.cet.
Where is wrong in my code? I've tried many solutions but they did not work either! Thanks in advance.

In reply to hash of arrays by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.