Yoda_Oz has asked for the wisdom of the Perl Monks concerning the following question:
the output of this is:#!/usr/bin/perl package Vehicle; sub new { my($class) = shift; my(%params) = @_; bless { "Engine" => $params{"Engine"}, "Doors" => $params{"Doors"} }, $class; } package Car; our @ISA = (Vehicle); sub new { my($class) = shift; my(%params) = @_; my($self) = Vehicle->new(@_); $self->{"Colour"} = $params{"Colour"}; return(bless($self, $class)); } package main; my $car = Car->new( "Engine" => "1800cc", "Doors" => "4", "Colour" => "blue"); print("I have an " . %{$car}->{'Engine'} . "\n"); print("I have " . %{$car}->{'Doors'} . "\n"); print("The color is " . %{$car}->{'Colour'} . "\n");
how can i change this code so that the output is this:I have an 1800cc I have 4 The color is blue
Obviously the inserted words (Engine, Doors and Colour) are within the hash on the left-hand-side. how do i get them to display as well as the ones on the right-hand-side, which already appear???I have an Engine 1800cc I have 4 Doors The color is Colour blue
Considered: rinceWind: "Dupe of 592857" Vote was Keep: 11, Edit: 0, Reap: 17
Unconsidered: davido: Sufficient keep votes and positive node reputation prevent reaping. Please don't reconsider.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash from package
by jbert (Priest) on Jan 04, 2007 at 09:31 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 09:43 UTC | |
|
Re: Hash from package
by GrandFather (Saint) on Jan 04, 2007 at 10:36 UTC | |
|
Re: Hash from package
by wfsp (Abbot) on Jan 04, 2007 at 09:28 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 09:32 UTC | |
by wfsp (Abbot) on Jan 04, 2007 at 09:45 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 10:13 UTC | |
|
Re: Hash from package
by Sagacity (Monk) on Jan 04, 2007 at 09:01 UTC | |
by Fletch (Bishop) on Jan 04, 2007 at 13:30 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 09:07 UTC | |
by reasonablekeith (Deacon) on Jan 04, 2007 at 09:40 UTC | |
|
Re: Hash from package
by bart (Canon) on Jan 04, 2007 at 12:03 UTC |