How to call a subroutine with a scaler with

B

blaine

Hi,

I would like to call a subroutine without using an eval statement that
has a scaler in the context.


ie.
my $class = FakeClass->new();
my $type = $class->GetType();

$class->DoSomething_$type();


Any ideas?
 
J

J. Gleixner

Hi,

I would like to call a subroutine without using an eval statement that
has a scaler in the context.


ie.
my $class = FakeClass->new();
my $type = $class->GetType();

my $method = "DoSomething_$type";
$class->DoSomething_$type();

$class->$method();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,212
Messages
2,571,101
Members
47,695
Latest member
KayleneBee

Latest Threads

Top