in reply to Hash from package

within the hash on the left-hand-side
Those are called keys

my %hash = qw(Engine 1800cc Doors 4 Color blue); for my $key (keys %hash){ print "$key -> $hash{$key}\n"; }
updated: straightened out the syntax

Replies are listed 'Best First'.
Re^2: Hash from package
by Yoda_Oz (Sexton) on Jan 04, 2007 at 09:32 UTC
    so how can i use that with my original post?:
    my %hash = qw(Engine 1800cc Doors 4 Color blue); for my $key (keys %hash){ print "$key -> $hash{$key}\n"; }
      for my $key (keys %{$car}){ print "$key -> $car->{$key}\n"; }
      Directly accessing the attributes of an object like that would likely be considered poor form.

      Have a look through the docs and look out for 'getters' and 'setters'.

      Object-Oriented Tutorial specifically discusses getters and setters.

      updated: added link to tutorial

        thanks man, ive been looking all day for some info on perl objects. much appreciated!