in reply to Re^3: How to Iterate to Identify Concurrent Users
in thread How to Iterate to Identify Concurrent Users

Randal,

>if one user logs in at 5, and leaves at 8, and another user >logs in at 6, and leaves at 9, and a third user logs in from >10 to 11, how many is that? Two, or Three, or none? :)

That would be 2, given your example. I mean the total number of simultaneous users on the system at a particular point in time. Any overlapping session of two users counts as two concurrent users. I hope this makes sense to the Greatest Monk of all ;-}
  • Comment on Re^4: How to Iterate to Identify Concurrent Users

Replies are listed 'Best First'.
Re^5: How to Iterate to Identify Concurrent Users
by GrandFather (Saint) on Oct 26, 2007 at 01:30 UTC

    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