Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Can't understand one line

by 7stud (Deacon)
on Jan 07, 2013 at 09:43 UTC ( #1011998=note: print w/ replies, xml ) Need Help??


in reply to Can't understand one line

use strict; use warnings; use 5.012; package Person; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub do_this { my($self, $greetee) = @_; say "hello $greetee"; } sub do_that { my($self, $greetee) = @_; say "goodbye $greetee"; } 1;
use strict; use warnings; use 5.012; use Person; my $obj = Person->new; $obj->do_this("Sam"); $obj->do_that("Cathy"); say '*' x 20; my @func_names = ('do_this', 'do_that'); my @names = ("Sam", "Cathy"); call_funcs(@names); sub call_funcs { for (@func_names) { $obj->$_(shift @_); } } --output:-- hello Sam goodbye Cathy ******************** hello Sam goodbye Cathy


Comment on Re: Can't understand one line
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-12-18 13:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls