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
In reply to Re: Subtracting values in two files
by CountZero
in thread Subtracting values in two files
by lorenz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |