Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Using $variable in place of "Method" in Module::Submodule::Method( @args )

by izut (Chaplain)
on Aug 23, 2006 at 19:25 UTC ( #569183=note: print w/replies, xml ) Need Help??


in reply to Using $variable in place of "Method" in Module::Submodule::Method( @args )

Here is an example:

#!/usr/bin/perl use strict; use warnings; package Module::MyModule; sub pass { my ($function, @args) = @_; my $f = \&{"Module::MyModule::" . $function}; return $f->(@args); } sub test { my (@args) = @_; return join ", ", @args; } package main; print Module::MyModule::pass("test", qw(1 2 3 4));

Update: modified to support strict.

Igor 'izut' Sutton
your code, your rules.

  • Comment on Re: Using $variable in place of "Method" in Module::Submodule::Method( @args )
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://569183]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2021-02-26 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?