in reply to matrices and non-numerical values
I would write that code as:I would appreciate any input on 1) code correctness
use strict; use warnings; open(IN, "list.txt") or die; chomp($line = <IN>); ($a, @ss) = split /\s+/, $line; while (chomp($line = <IN>)) { ($aa, @prs) = split /\s+/, $line; for ($i=0; $i<@prs; $i++) { $s{$aa}{$ss[$i]} = $prs[$i]; } } close(IN);
use strict; use warnings; open my $IN, '<', 'list.txt' or die "Cannot open 'list.txt' because: $ +!"; my ( undef, @ss ) = split ' ', <$IN>; my %s; while ( <$IN> ) { my ( $aa, @prs ) = split; @{ $s{ $aa } }{ @ss } = @prs; } close $IN;
|
|---|