in reply to Problem printing/storing hash

I made some minor mods. I would suggest that you enable strict; (you will have to do some work to get it so that it doesn't complain).
Update: Possible recoding below...
#!/usr/bin/perl -w #use strict; #### I would recommend you do this!!! # Takes input in the form 'a,b|c' # How to run : perl code.pl 'a,b|c' 'c,d|e' 'a,d|e' # Outputs a NX3 for the above input data. # Outputs connections in Nx2 form use Data::Dumper; print "@ARGV\n"; $arg=join(' ',@ARGV); @det=split //, $arg; for ($i=0; $i <=8; $i++) {$trip[$i]=$det[2*$i];} my @array; while (@trip) { push(@array, [ splice(@trip, 0, 3) ]); } print "@$_\n" for @array; for ($i=0; $i <=2; $i++) { for ($j=0; $j <=1; $j++) { $con[$i][$j]=$array[$i][$j];} } print Dumper \@con; #### use the Dumper! print "\n==========connections======\n"; print "from->to\n"; print " @$_\n" for @con; my %HoA; foreach my $rowref (@con) { #each @con is a ref to row ($key, $value) = @$rowref; push @{$HoA{$key}}, $value; } # PRINTING THE HASH foreach (keys %HoA) { print "$_ => @{$HoA{$_}}\n"; #was missing a curly pair } __END__ C:\TEMP>perl hasharray.pl "a,b|c" "c,d|e" "a,d|e" a,b|c c,d|e a,d|e a b c c d e a d e $VAR1 = [ [ 'a', 'b' ], [ 'c', 'd' ], [ 'a', 'd' ] ]; ==========connections====== from->to a b c d a d c => d a => b d
Update:

Maybe I'm missing something but this seems to be overly complex. Maybe this is all that is needed?

#!/usr/bin/perl -w use strict; # Takes input in the form 'a,b|c' # How to run : perl code.pl 'a,b|c' 'c,d|e' 'a,d|e' # Outputs a NX3 for the above input data. # Outputs connections in Nx2 form use Data::Dumper; print "Input args are: @ARGV\n"; my %hash; foreach my $input (@ARGV) { my($key, $value ) = ($input =~ m/\w/g)[0,1]; #not sure what role if any the |c or |e plays in this? push @{$hash{$key}}, $value; } print Dumper \%hash; __END__ C:\TEMP>perl hasharray2.pl "a,b|c" "c,d|e" "a,d|e" Input args are: a,b|c c,d|e a,d|e $VAR1 = { 'c' => [ 'd' ], 'a' => [ 'b', 'd' ] };