xenchu has asked for the wisdom of the Perl Monks concerning the following question:
Perl told me the syntax was ok but when I ran it I got the following error messages:#!/usr/bin/perl # indexhash.pl use warnings; use strict; #create a hash with integrated index my %hash = { Mouse => {Index => 0, Value => 'Jerry'}, Cat => {Index => 1, Value => 'Tom'}, Dog => {Index => 2, Value => 'Spike'} }; # sort a hash by integrated index foreach (sort {$hash{$a} {'Index'} cmp $hash{$b} {'Index'}} keys %hash +) { print "$hash{$_} {'Value'} <= $_ \n"; }
My question is twofold. First, assuming I can read and type what is the error? Second, does any Perl Monk have an opinion on this book and is it worth using?Reference found where even-sized list expected at indexhash.pl line 7. Use of uninitialized value in concatenatization (.) or string at index +hash.pl line 16.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Book Code
by liz (Monsignor) on Nov 15, 2003 at 19:57 UTC | |
|
Re: Book Code
by pg (Canon) on Nov 15, 2003 at 20:04 UTC | |
|
Re: Book Code
by xenchu (Friar) on Nov 15, 2003 at 21:28 UTC | |
by mooseboy (Pilgrim) on Nov 16, 2003 at 08:13 UTC | |
by merlyn (Sage) on Nov 16, 2003 at 16:56 UTC | |
|
Re: Book Code
by Anonymous Monk on Nov 15, 2003 at 19:58 UTC |