[Chicago-talk] print keys for anon hash

Kearney, Tim tkearney at fastweb.com
Mon Dec 15 09:50:55 CST 2003

# for the first anonymous hash
foreach my $key (keys %{$crew[0]}) {
  print "found $key\n";

# for the second anonymous hash
foreach my $key (keys %{$crew[1]}) {
  print "found $key\n";

# etc.

-- Tim

-----Original Message-----
From: Dooley, Michael [mailto:Dooley.Michael at con-way.com]
Sent: Monday, December 15, 2003 9:44 AM
To: Chicago.pm chatter
Subject: [Chicago-talk] print keys for anon hash

How do I print out the keys for a specific anon hash?

if I say print $crew[0]{'name'},"\n"; I can get the name of a specific key
but what if I wanted all the keys for that anon hash?

am I missing something?

#!/usr/bin/perl -w
use strict;
my @crew = (
                name => 'Gilligan',
                hat => 'White',
                position=>'first mate',
                name => 'Skipper',
                hat => 'Black',

print keys ($crew[0]),"\n";

Type of arg 1 to keys must be hash (not array element) at ./test.pl line 20,
near "])"
Execution of ./test.pl aborted due to compilation errors.

Chicago-talk mailing list
Chicago-talk at mail.pm.org

"Bringing people together to advance their lives." 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20031215/b1c39f61/attachment.htm

More information about the Chicago-talk mailing list