in reply to Subtracting values in two files
use Modern::Perl; use List::MoreUtils qw/pairwise/; use autodie; open my $in1, './file1.dat'; open my $in2, './file2.dat'; while (my $first = <$in1> and my $second = <$in2>) { my @first = split / /, $first; my @second = split / /, $second; my @result = pairwise {$a - $b} @first, @second; say "@result"; }
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^2: Subtracting values in two files
by lorenz (Novice) on May 23, 2011 at 19:06 UTC |