Added an optional @args onto event_run() for sending @args to the subs that have hooked onto the event.
This commit is contained in:
1 parent
3afdcfd374
commit
e0ad8bd911
2 files changed
+9
-2
No files matched your search
+7
-2
@@ -135,11 +135,16 @@ sub event_del
|
||||
# Trigger an event.
|
||||
sub event_run
|
||||
{
|
||||
my ($event) = @_;
|
||||
my ($event, @args) = @_;
|
||||
|
||||
if (defined $EVENTS{lc($event)} and defined $HOOKS{lc($event)}) {
|
||||
foreach my $hk (keys %{ $HOOKS{lc($event)} }) {
|
||||
&{ $HOOKS{lc($event)}{$hk} }();
|
||||
if (defined @args) {
|
||||
&{ $HOOKS{lc($event)}{$hk} }(@args);
|
||||
}
|
||||
else {
|
||||
&{ $HOOKS{lc($event)}{$hk} }();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user