Yoda_Oz has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
im having a small problem. im completely stuck and i dont know how to get unstuck...
i have some code here:
does anyone get what i mean?
my output is nothing. no errors, nothing. just blank.
i was hoping to get printed, this:
i have some code here:
im trying to learn inheritance packages here and i cant seem to get a hold of it. what im trying to do is print out something from one package and all it's inheritances too...#!/usr/bin/perl use strict; use warnings; package Vehicle; sub new { my $class = @_; my $self = { _engine => "I have an engine.", _wheel => "I have wheels.", _door => "I have doors." }; bless $self, $class; return $self; } package Private; sub new { my $class = @_; my $self = { _Vehicle => new Vehicle(), _private => "I am private" }; bless $self, $class; return $self; } package Family; sub new { my $class = @_; my $self = { _Private => new Private(), _passengers => "I carry 5 passengers", _goods => "I carry 50lbs" }; bless $self, $class; return $self; } package main; my $car = new Family(); foreach $car (sort keys my %hash) { print "$car => $hash{$car}\n"; }
does anyone get what i mean?
my output is nothing. no errors, nothing. just blank.
i was hoping to get printed, this:
I have an engine I have doors I have wheels I am private I carry 5 passengers I carry 50lbs
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Stuck on packages
by Trimbach (Curate) on Jan 04, 2007 at 04:29 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 04:46 UTC | |
by duckyd (Hermit) on Jan 04, 2007 at 06:25 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 06:43 UTC | |
by SheridanCat (Pilgrim) on Jan 04, 2007 at 07:16 UTC | |
| |
by SheridanCat (Pilgrim) on Jan 04, 2007 at 07:22 UTC | |
| |
Re: Stuck on packages
by GrandFather (Saint) on Jan 04, 2007 at 03:45 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 03:59 UTC | |
Re: Stuck on packages
by mreece (Friar) on Jan 04, 2007 at 06:38 UTC | |
Re: Stuck on packages
by Tanktalus (Canon) on Jan 04, 2007 at 15:34 UTC | |
by GrandFather (Saint) on Jan 04, 2007 at 20:09 UTC |
Back to
Seekers of Perl Wisdom