Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by VinsWorldcom (Prior)
on Apr 02, 2019 at 21:28 UTC ( #1232052=note: print w/replies, xml ) Need Help??


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

That's OK, from examples above:

use strict; use warnings; package Object; sub new { return bless \{} } sub foo { printf "hello foo = %s\n", ( caller(0) )[3]; } sub bar { printf "hello bar = %s\n", ( caller(0) )[3]; } package main; my $someObject = Object->new(); my $someCondition = 0; my $funcname = ( $someCondition ? 'foo' : 'bar' ); $someObject->$funcname($funcname); $someCondition = 1; $funcname = ( $someCondition ? 'foo' : 'bar' ); $someObject->$funcname($funcname);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2020-05-26 18:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (150 votes). Check out past polls.

    Notices?