in reply to Re^2: Refactoring a module with many anonymous subrefs as an OO module
in thread Refactoring a module with many anonymous subrefs as an OO module

That's certainly better than the 1,1 you were passing earlier. You could also iterate over the hash and build up accessors.

while ( my ( $name, $code ) = each %hash ) { no strict 'refs'; *$name = $code; }

And then you could just call:

$x->blah;

That provides a couple of advantages. First, you don't have to remember to check if the key in the hash exists (as I forgot to do in my example to you). Second, you can gain a limited bit of introspection:

if ( my $method = $x->can('blah') ) { $x->$method; }

However, beyond your example, I don't really know what your needs are, so this may not work for you.

Cheers,
Ovid

New address of my CGI Course.

Replies are listed 'Best First'.
Re^4: Refactoring a module with many anonymous subrefs as an OO module
by telcontar (Beadle) on Nov 22, 2007 at 09:38 UTC
    Thanks a lot. You were of immense help.

    -- telcontar