So you mean (to quote from my earlier post) "A list indicating the number of concurrent users whenever that number changes". Something like this:
use strict;
use warnings;
my @events = qw(1+ 3+ 4- 5+ 5+ 6- 6- 6- 9+ 10-);
my $lastEpoch = 0;
my $conections = 0;
for (@events) {
my ($epoch, $event) = /(\d+)(.)/;
print "$lastEpoch: $conections\n" if $lastEpoch and $lastEpoch !=
+$epoch;
$event eq '+' ? ++$conections : --$conections;
$lastEpoch = $epoch;
}
print "$lastEpoch: $conections\n";
Prints:
1: 1
3: 2
4: 1
5: 3
6: 0
9: 1
10: 0
Perl is environmentally friendly - it saves trees
|