in reply to Putting text file into a hash

to help debug: use warnings; use strict; change (my $word1,my $word2)= split /:/, $line; to my ($word1, $word2)= split /:/, $line;

Replies are listed 'Best First'.
Re: Putting text file into a hash
by targetsmart (Curate) on Oct 21, 2008 at 08:12 UTC
    One another solution
    perl -MData::Dumper -e 'my ($Key,$Value) = split (/:/) ; $hash{$Key} = + $Value ;END{print Dumper \%hash};' -ln 'filename'
    But the above code will not handle error conditions.