/usr/share/perl5/Net/IRC/EventQueue.pm is in libnet-irc-perl 0.79-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | package Net::IRC::EventQueue;
use Net::IRC::EventQueue::Entry;
use strict;
sub new {
my $class = shift;
my $self = {
'queue' => {},
};
bless $self, $class;
}
sub queue {
my $self = shift;
return $self->{'queue'};
}
sub enqueue {
my $self = shift;
my $time = shift;
my $content = shift;
my $entry = new Net::IRC::EventQueue::Entry($time, $content);
$self->queue->{$entry->id} = $entry;
return $entry->id;
}
sub dequeue {
my $self = shift;
my $event = shift;
my $result;
if(!$event) { # we got passed nothing, so return the first event
$event = $self->head();
delete $self->queue->{$event->id};
$result = $event;
} elsif(!ref($event)) { # we got passed an id
$result = $self->queue->{$event};
delete $self->queue->{$event};
} else { # we got passed an actual event object
ref($event) eq 'Net::IRC::EventQueue::Entry'
or die "Cannot delete event type of " . ref($event) . "!";
$result = $self->queue->{$event->id};
delete $self->queue->{$event->id};
}
return $result;
}
sub head {
my $self = shift;
return undef if $self->is_empty;
no warnings; # because we want to numerically sort strings...
my $headkey = (sort {$a <=> $b} (keys(%{$self->queue})))[0];
use warnings;
return $self->queue->{$headkey};
}
sub is_empty {
my $self = shift;
return keys(%{$self->queue}) ? 0 : 1;
}
1;
|