On Sat, Dec 27, 2008 at 06:10, bacoms <googlebr...@balfour.me.uk> wrote: > Ho, I wanted to declare an HTML list as a constant array and then > print it but cannot work out the stntax. > > This is what I've coded; > > use constant NAVTABSLIST => ["<div id='header'>\n", snip > pr...@navtabslist. snip
You may be better served by the Readonly module*. It allows you to make variables into constants: Readonly @nav_tabs_list => ("<div id='header'>\n", etc. ); Any attempt to modify @arr will throw an error. What you have is a constant reference to a mutable array. It is still legal to say NAVTABSLIST->[0] = "ha ha, I changed you"; But to answer your question try #!/usr/bin/perl use strict; use warnings; use constant ARRAY => [1,2,3,4,5]; print @{ARRAY()}, "\n"; This works because the constant ARRAY is really the function sub ARRAY() { return [1,2,3,4,5] } * http://search.cpan.org/dist/Readonly/Readonly.pm -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/