in reply to Re^2: Completing a list/ array?
in thread Completing a list/ array?
Output:use Modern::Perl; no warnings qw /uninitialized /; my @result; while (<DATA>) { chomp; my ($index, $value) = split /\t/; $result[$index] = $value; } $result[50] = 0 unless $result[50]; while (my ($index, $value) = each @result) { next if $index == 0; say "$index\t", $value+0; } __DATA__ 33 5 34 7 36 7 37 8 38 0
1 0 2 0 3 0 4 0 5 0 6 0 7 0 (...) 31 0 32 0 33 5 34 7 35 0 36 7 37 8 38 0 39 0 (...) 49 0 50 0
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Completing a list/ array?
by Taylorswift13 (Novice) on Nov 12, 2011 at 16:41 UTC | |
by CountZero (Bishop) on Nov 12, 2011 at 18:22 UTC |