in reply to sub by reference - assigning to an object?
You're trying to assign to a method, which isn't going to work without some deep magic (and even then that's probably not what you want to do). You really want the subref to either be passed as a parameter to the constructor ($parser_name->new( getDBH => \&getDBH )) and/or stored in an attribute ($self->{ 'getDBH_sub' } = \&getDBH) and then the parser instances use that to call the proper routine that way.
Update: So to elaborate, basically each parser class' getDBH routine would look something like this:
sub getDBH { my $self = shift; my $getDBH_ref = $self->{ 'getDBH_sub' }; $getDBH_ref->( ); }
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sub by reference - assigning to an object?
by ethrbunny (Monk) on Mar 26, 2008 at 16:47 UTC | |
by Arunbear (Prior) on Mar 26, 2008 at 17:23 UTC |