cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:
hi all
I know this doesn't work:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $var = {'one','two','red','blue'}->{'fish'}; print Dumper($var); # wanting this # $var->{'one'}->{'fish'} # $var->{'two'}->{'fish'} # etc
But why does Dumper output undef instead of an error?
And does anyone have a succinct way of doing what I'd like it to do? The example above is simplified to show weird issue. In real life, fish is a hashref, eg:
my $mime = { 'Web Page' => { icon => 'webdoc.png', ext => ['htm','html','shtml'], }, 'PHP Web Page' => { icon => 'webdoc.png', ext => ['php'], }, 'Perl' => { icon => 'script.png', ext => ['cgi','pm','pl'], }, };
What I really want is to grab the ext values and use them as keys, moving the description to the hashref value hashref.
But the above is easier to read, even if it doesn't help me find attr for files based on extension.
Or should I just forget and use the above to create a new hashref with everything in the right order on script run?Hmmm mumble mumble
cLive ;-)
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strict and warnings but no error?
by blokhead (Monsignor) on May 28, 2003 at 02:12 UTC | |
|
Re: strict and warnings but no error?
by japhy (Canon) on May 28, 2003 at 02:18 UTC | |
|
Re: strict and warnings but no error?
by Zaxo (Archbishop) on May 28, 2003 at 02:15 UTC | |
|
Re: strict and warnings but no error?
by japhy (Canon) on May 28, 2003 at 02:13 UTC | |
|
Re: strict and warnings but no error?
by cLive ;-) (Prior) on May 28, 2003 at 02:26 UTC |