in reply to calling methods using a variable
Here's a quick replication of your problem:
use strict; use CGI; my $q = CGI->new; my $good_method = "param"; my $bad_method = "param('foo')"; print $q->$good_method( 'foo' ); print $q->$bad_method;
To fix it, make an array of array refs with the second item being your arguments:
@commands = ( ['add_node','W1'], ['add_node','W2'], ['add_edge,'W2' => 'W1'] ); use GraphViz; my $g = GraphViz->new(); foreach (@commands) { my ( $command, @args ) = @$_; $g->$command( @args ); }
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: calling methods using a variable
by Kanji (Parson) on Mar 22, 2002 at 00:48 UTC |