On Sat, 2008-12-27 at 03:10 -0800, bacoms 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", > " <ul id='nav-tabs'> > \n", > " <li><a > href='#'><span>Home</span></a></li>\n", > " <li><a > href='#'><span>Table</span></a></li>\n", > " <li><a > href='#'><span>Chart</span></a></li>\n", > " </ul>\n", > "</div>\n"]; > > Although I can print for example "print NAVTABSLIST->[1];" i can't > figure out how to print the whole array just like I'd coded: > > my @NAVTABSLIST = ("<div id='header'>\n", > " <ul id='nav-tabs'>\n", > " <li><a href='#'><span>Home</ > span></a></li>\n", > " <li><a href='#'><span>Table</ > span></a></li>\n", > " <li><a href='#'><span>Chart</ > span></a></li>\n", > " </ul>\n", > "</div>\n"); > > pr...@navtabslist. > > Is there a way of doing this? Many thanks. > >
print @{ &NAVTABSLIST }; print @{ NAVTABSLIST() }; use Data::Dumper; print Dumper NAVTABSLIST; Perl does not have true constants. What `use constant` does is create a sub that returns the value. That means you can use it as a sub in all your code. -- Just my 0.00000002 million dollars worth, Shawn Believe in the Gods but row away from the rocks. -- ancient Hindu proverb -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/