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.

It would be a lot simpler if you set up a constant list instead of constant ref
array.

HTH,

Rob


use strict;
use warnings;

use constant NAVTABSLIST => (
  "<div id='header'>\n",
  "  <ul id='nav-tabs'>\n",
  "    <li><ahref='#'><span>Home</span></a></li>\n",
  "    <li><ahref='#'><span>Table</span></a></li>\n",
  "    <li><ahref='#'><span>Chart</span></a></li>\n",
  "  </ul>\n","</div>\n"
);

print NAVTABSLIST;

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to