Skip Menu |

This queue is for tickets about the Module-Pluggable-Ordered CPAN distribution.

Report information
The Basics
Id: 69558
Status: new
Priority: 0/
Queue: Module-Pluggable-Ordered

People
Owner: Nobody in particular
Requestors: civil.over [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Can't pass parameters to constructor of class in plugin
Date: Tue, 19 Jul 2011 02:45:29 +0400
To: bug-Module-Pluggable-Ordered [...] rt.cpan.org
From: Civil <civil.over [...] gmail.com>
I'm trying to use Module::Pluggable::Ordered to make OOP-based plugins. I pass parameter (ref to hash) in constructor. I write this code: use Module::Pluggable::Ordered search_path => ['Lxctl::plugins::set'], instantiate => "new"; <...> sub AUTOLOAD { my $self = shift; my ($function) = $AUTOLOAD =~ m/.*::(.*)$/; if ($function eq "DESTROY") { return; } for my $plugin ($self->plugins_ordered(\%options)) { eval { $plugin->$function(@_); print "Called $plugin->$function\n"; } } } What I expect: ref to %options is passed to constructor What I've got: Can't use an undefined value as a HASH reference at Lxctl/plugins/set/ base.pm line 170 (#1) (F) A value used as either a hard reference or a symbolic reference must be a defined value. This helps to delurk some insidious errors. Possible solution: in Ordered.pm change line 58 from: --- /usr/share/perl5/Module/Pluggable/Ordered.pm 2011-07-19 02:44:25.576616775 +0400 +++ Ordered.pm 2011-07-19 02:44:21.786611227 +0400 @@ -55,7 +55,7 @@ *{"${caller}::${subname}_ordered"} = sub { my $thing = shift; - my @plugins = $thing->$subname(); + my @plugins = $thing->$subname(@_); $_->require for @plugins; return map { $_->[0] } I don't know perl quite well, so I don't think it's propper fix, but at least it works for my tasks. Best regards, Vladimir Smirnov.