[Chicago-talk] print keys for anon hash

Dooley, Michael Dooley.Michael at con-way.com
Mon Dec 15 09:44:07 CST 2003

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.


More information about the Chicago-talk mailing list