in reply to Simple Perl If Else Statement
Data is possibly a spreadsheet.
use strict; use warnings; my ($B,$I,$K,$S); while (<DATA>) { chomp; last unless ($_); ($B,$I,$K,$S) = (split /,/,$_)[1,8,10,18]; if ($I == $B) { $K = abs($K); } elsif ($I == $S) { $K = -1 * abs($K); } print "$K\n"; } __DATA__ 0,2,0,0,0,0,0,0,2,0,1,0,0,0,0,0,0,0,3 0,2,0,0,0,0,0,0,3,0,1,0,0,0,0,0,0,0,3 0,2,0,0,0,0,0,0,4,0,-5.5,0,0,0,0,0,0,0,3
Output:
1 -1 -5.5
Update: $K = -1 instead of $K *= -1
|
|---|