'Chuck' is returned. You're just not seeing it because it's sitting in the STDOUT buffer while the computer sleeps for 30 seconds, rather than being flushed to the screen. You need to put a "\n" at the end of your print statement.
print $array[0]->{name}, "\n";
That ought to do it.
The issue really has nothing to do with arrays of hashes, and everything to do with output buffering.
Without the "\n" you're not guaranteed of having the output buffer get flushed to the screen, even when the program ends, though most OS's will flush it upon termination.
What is happening is 'Chuck' gets put into the output buffer, the program sleeps for 30 seconds, the program reaches its termination, the output buffer gets flushed to the screen, and poof, your Microsoft DOS emulation window disappears on you before you can blink. Adding the "\n" newline tells Perl to flush the terminal's buffer.
Note, "\n" causes terminal-tied buffers to flush, but doesn't necessarily flush other types of file handles (such as ones tied to files on your hard drive or a network socket). If you want to force all your "pipes to be piping hot" (force them to flush with each print), set a non-zero value in the output-autoflush system special variable, $|. Be aware that this will have a performance impact on every file-related thing you do in your program. Buffers exist for a reason. Try to avoid setting the autoflush variable unless you really need it. In your specific case, all you needed was a newline.
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein |