This kind of thing is redundant and error-prone. That's why we have array slices!@date1 = ($dt[0], $dt[1], $dt[2], $dt[3], $dt[4], $dt[5]);
Another redundancy:@date1 = @dt[0..5];
You've replaced it with a loop that calls Add_Delta_DHMS on every line, not just once per twelve lines, so it's not equivalent at all. I would tend to write something like this:chomp($line1); my @mg1 = split(/,/, $line1); my $line2 = <IN>; chomp($line2); my @mg2 = split(/,/, $line2); my $line3 = <IN>; chomp($line3); ...
my ($sum) = split /,/, $line; for (2..12) { my ($val) = split /,/, <IN>; $sum += $val; }
In reply to Re: What can I do to improve my code - I'm a beginner
by Anonymous Monk
in thread What can I do to improve my code - I'm a beginner
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |