in reply to looping over constant data structure references
Use [ MSG_DATA ] elsewhere in the code if you need to use the list as an reference.use Data::Dumper; use constant MSG_DATA => { foo => 1 }, { bar => 2 }, { baz => 3 }; for my $msg (MSG_DATA) { print Dumper $msg; }
Incidentally, this feature is the source of many accidental bugs with constant:
The programmer probably meant to declare three constants, not one:use constant FOO => "xyz", BAR => "def", BAZ => "abc"; # FOO returns qw/xyz BAR def BAZ abc/ # BAR and BAZ aren't defined as constants
use constant { FOO => "xyz", BAR => "def", BAZ => "abc" };
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: looping over constant data structure references
by leriksen (Curate) on Nov 11, 2003 at 05:09 UTC |