Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^6: Perl "new" command

by JavaFan (Canon)
on Mar 01, 2012 at 12:51 UTC ( [id://957201]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package Colour;
    sub new {bless {colour => $_[1]}, $_[0]}
    ...
    package Age;
    sub new {bless {age => $_[1]}, $_[0]}}
    sub age {$_[0]{age}}
    
  2. or download this
    use Colour;
    use Age;
    ...
    my $a_obj = Age::->new(42);
    print "I have an object with colour ", $c_obj->colour;
    print "And another object aged ", $a_obj->age;
    
  3. or download this
    package Age_and_Colour;
    use Age;
    ...
        my ($class, $age, $colour) = @_:
        ... Now what? ...
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-23 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found