Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Function name in a variable, can't recall the concept

by tybalt89 (Monsignor)
on Apr 02, 2019 at 14:50 UTC ( [id://1232018]=note: print w/replies, xml ) Need Help??


in reply to Function name in a variable, can't recall the concept

Note that 'symbolic names' work perfectly fine as 'method names' under strict and warnings :)

#!/usr/bin/perl # https://perlmonks.org/?node_id=1232013 use strict; use warnings; my $someCondition = 0; my $arg1 = 'arg1'; my $arg2 = 'arg2'; my $funcname = ( $someCondition ? 'foo' : 'bar' ); SomeClass->$funcname($arg1, $arg2); package SomeClass; sub foo { print "in 'foo' with args: @_\n" } sub bar { print "in 'bar' with args: @_\n" }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-24 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found