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? ...
    }