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

RE: Re: Blessed be the OOP'ers

by chromatic (Archbishop)
on Jun 29, 2000 at 02:26 UTC ( #20279=note: print w/ replies, xml ) Need Help??


in reply to Re: Blessed be the OOP'ers
in thread Blessed be the OOP'ers

More specifically, the original code could be written this way: my $employees = [];
Hopefully that makes it clear that a list enclosed in square brackets is an anonymous list. Assigning that somewhere creates a reference. (That's why you can stuff it in a scalar.)

The original code creates @employees and sets the first (and only) element to a reference to that anonymous list.


Comment on RE: Re: Blessed be the OOP'ers
Download Code
RE: RE: Re: Blessed be the OOP'ers
by pemungkah (Priest) on Jun 29, 2000 at 02:34 UTC
    And the push would then be
    push @$employees, $person;
    
    with printing them looking like
    foreach $p (@$employees) {
       print $p->name(),"\n";
    }
    
    Using the array reference would make it easy to stuff this list of employees into another object/list/whatever.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (16)
As of 2015-07-01 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (11 votes), past polls