The code above was designed to be called as a class method, meaning:{ my %cache; my $statements = sub { my $h = shift; local $/ = ";"; chomp(my @sql = <$h>); return grep /\S/, @sql; }; sub run_data_sql { my $class = shift; no strict 'refs'; $cache{$class} ||= [ $statements->(*{"$class\::DATA"}{IO}) ]; $class->db_Main->do($_) foreach @{$cache{$class}}; return 1; } }
The key would be to replace:My::Class->run_data_sql
withmy $class = shift;
so that the sub could be called as an object method:my $class = ref shift();
and not a class method and then work out its original class via ref$object->run_data_sql
Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Working around non-polymorphic __DATA__ sections
by hardburn (Abbot) on Oct 20, 2003 at 13:38 UTC | |
by princepawn (Parson) on Oct 20, 2003 at 15:52 UTC | |
|
Re: Working around non-polymorphic __DATA__ sections
by simonm (Vicar) on Oct 20, 2003 at 18:46 UTC | |
|
Re: Working around non-polymorphic __DATA__ sections
by Anonymous Monk on Oct 21, 2003 at 09:32 UTC |