perl - Argument "*" isn't numeric in array element -


i want make hash of array file looks like:

xx500173:56qwer  45      rtt34  34c ... 

i have unique "key" (e.g. column1_column2)

#!/usr/bin/perl use warnings; use strict;   $seq; while(<>){ chomp; @line = split(/\s+/, $_);  $key = $line[0] . "_" . $line[1]; #try make unique key each entry  map { $seq->{ $_->[$key] } = [@$_[0..4]] } [ split/\s+/ ]; }  foreach $s (keys %{$seq} ) { print $s,": ",join( "\t", @{ $seq->{$s}} ) . "\n"; } 

but following error:

argument "xx500173:56qwer_45" isn't numeric in array element 

does matter if key numeric or string?

an index array [] should numeric, $key not numeric. assuming want white-space-separated tokens elements of array:

use warnings; use strict;  $seq; while (<data>) {     chomp;     @line = split;     $key = $line[0] . "_" . $line[1]; #try make unique key each entry     $seq->{$key} = [ @line ]; }  foreach $s ( keys %{$seq} ) {     print $s, ": ", join( "\t", @{ $seq->{$s} } ) . "\n"; }  __data__ xx500173:56qwer  45      rtt34  34c 

outputs:

xx500173:56qwer_45: xx500173:56qwer     45            rtt34   34c