"I need to parse through the array and take teh time of the first Event A, and then find the first Event B after Event A, and calculate the time delta."
And then what? Do you look for the next Event A and use it as the base to find the delta against the next Event B or do you go all the way back to the 2nd Event A that you found in the first iteration? All the answers given so far seem to pick the later, but i'm choosing the former and providing a solution that uses a hash. :) Hope this helps!
use strict; use warnings; my %h; while (<DATA>) { chomp; ($a,$b) = split; if ($a eq 'a') { $h{a} ||= $b; } elsif ($a eq 'b') { print $b - $h{a}, $/; %h = (); } } __DATA__ a 123 a 125 b 127 a 129 a 130 b 131 a 132 b 133
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: processing a list of events
by jeffa
in thread processing a list of events
by BluePerlDev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |