in reply to Learning about Arrays and Hashes - printing pieces of them
You have an error in the LOOKUP hashref. Here’s a simplified version that will output what you expect–
use strict; use warnings; my $rec = { TEXT => "Fred loves Ethel", SEQUENCE => [ 13, 27, 47, 98 ], LOOKUP => { cars => 'Buick', dog => 'hound' } }; print $rec->{TEXT}, "\n", $rec->{SEQUENCE}[0], "\n", $rec->{LOOKUP}{dog}, "\n";
Notes — Find the difference between your LOOKUP and mine. Always use strict and warnings (at least when starting). You can pass a list of things to print so only one is necessary. The newlines generally have to be asked for as well. Welcome to the monastery and good luck with Perl! It’s a terrific language.
(Update: LanX usually welcomes newcomers… Sorry you had to settle for me. :P)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Learning about Arrays and Hashes - printing pieces of them
by Anonymous Monk on Jan 28, 2015 at 19:56 UTC | |
by NetWallah (Canon) on Jan 28, 2015 at 20:10 UTC |