Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2015-11-26 00:02 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (693 votes), past polls