You seem to be not just passing an array, but passing an array of hashes. There may be a way that the wonderful wonderful CGI.pm handles this data structure, but if there is I don't know it. I would have thought it would be easier to break your data up into several name/value pairs, since that's what it is anyway, and save each pair in its own hidden variable.
I know it's not what you asked about, but could I offer some observations on your use of CGI.pm? I've only recently started using it, so I'm not a huge expert, but I'm enthusiastic to share what works for me.
I notice you import
:all the CGI functions, but you then go ahead and create a CGI object as well - that, I think, is redundant. For what you are doing I think it wd be simpler to stick with the function-oriented interface. Also, you don't need
:all the functions:
use CGI qw/:standard/; should suffice.
Then, having imported these functions (either explicitly, or implicitly by creating the CGI object) you might as well get your money's worth, and use them to create your html. To show how you could do that I've re-written
Header:
print
header,
start_html(-title => 'Pass the array'),
h1('Array:'),
(left off the last two lines since most times you'll get black text on white background by default). I think that's a lot easier to write and read, and it's also harder to get typos that can't be found but make a mess.
That probably makes it short enough that you might not put it in a subroutine. But if you do, it strikes me that it's asking for trouble to give that subroutine (almost) the same name as a function that you just imported from CGI.pm.
Sorry to go on about something you didn't ask about - hope some of it's useful.
§
George Sherston
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.