perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
Instead of the value of Page, '1', being used as a key, the string 'Page' is being used. If a literal value of page was being used to initialize %map, wouldn't I get a strict warning about using an unquoted string?#/usr/bin/perl -w use strict; use constant { Undefined => 0, Page => 1, Index => 2, }; my %map = ( Page => 'mypage', Index => 'myindex', ); foreach my $k (keys %map) { printf "key=%s, val=%s\n", $k, $map{$k}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why doesn't constant work?
by ikegami (Patriarch) on Nov 11, 2010 at 05:07 UTC | |
|
Re: why doesn't constant work?
by roboticus (Chancellor) on Nov 11, 2010 at 04:19 UTC | |
by perl-diddler (Chaplain) on Nov 11, 2010 at 04:21 UTC | |
by Tanktalus (Canon) on Nov 11, 2010 at 04:41 UTC | |
by ELISHEVA (Prior) on Nov 11, 2010 at 13:39 UTC | |
by JavaFan (Canon) on Nov 11, 2010 at 14:08 UTC | |
by roboticus (Chancellor) on Nov 11, 2010 at 04:27 UTC | |
|
Re: why doesn't constant work?
by moritz (Cardinal) on Nov 11, 2010 at 07:18 UTC | |
|
Re: why doesn't constant work?
by BrowserUk (Patriarch) on Nov 11, 2010 at 04:22 UTC | |
|
Re: why doesn't constant work?
by TomDLux (Vicar) on Nov 11, 2010 at 15:21 UTC |