>>>>> "IG" == Ishwor Gurung <ishwor.gur...@gmail.com> writes:

  IG> [isg@tarzan:perl]# cat -n foo.pl

don't post code with line numbers. then it can't be cut/pasted by
others.


  IG>      1    #!/usr/bin/env perl
  IG>      2    use warnings;
  IG>      3    use strict;
  IG>      4    use Data::Dumper;
  IG>      5    open FH,"<", "/tmp/foo" || die "aww... $!";

don't use bareword file handles. use lexical handles.

  IG>      6    my $i = {};

no need to initialize that to a hash ref. autovivification will do that
for you.

  IG>      7    while(<FH>)
  IG>      8    {
  IG>      9        chop;

use chomp as it is safer.

  IG>     10        my ($key, $value) = split(/\space/,$_);

what is \space? that is actually \s (a space char) followed by 'pace'
which isn't in the input stream.

  IG>     11        push $@{$i->{$key}},$value; # push $value into $i->{$key}

why is there a $ before the @? that isn't legal perl. it means you
didn't run the code that you posted.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to