I'm using Template.pm to experiment with some Perl code. In the documentation it explains that you can create loops with repeating values. Here is the relative section I'm talking about for those who don't have Template.pm.
The <TMPL_LOOP> tag is a bit more complicated than <TMPL_VAR>. The <TMPL_LOOP> tag allows you to delimit a section of text and give it a name. Inside this named loop you place <TMPL_VAR>s. Now you pass to param() a list (an array ref) of parameter assignments (hash refs) for this loop. The loop iterates over the list and produces output from the text block for each pass. Unset parameters are skipped. Here's an example: In the template: <TMPL_LOOP NAME=EMPLOYEE_INFO> Name: <TMPL_VAR NAME=NAME> <br> Job: <TMPL_VAR NAME=JOB> <p> </TMPL_LOOP> In the script: $template->param(EMPLOYEE_INFO => [ { name => 'Sam', job => 'progra +mmer' }, { name => 'Steve', job => 'soda + jerk' }, ] ); print $template->output(); The output in a browser: Name: Sam Job: programmer Name: Steve Job: soda jerk As you can see above the <TMPL_LOOP> takes a list of variable assignments and then iterates over the loop body producing output.
Alright. Not a problem. Building the specific Perl code, and implementing it as described causes no problems.
So I wanted to learn more about how this code worked so I kept reading through the file and experimenting.

Apparently, I'm not having much luck in understanding this. I think it's either because the only time I have to play with Perl for the last several weeks is between 10:00 PM and 1:00 AM, or the total program is just so large and complex, so my poor brain just can't wrap itself around this.

Whenever I experiment with this, I always get a "Pseudo-hashes deprecated" message. I even found a very similar example, but running that example yields an identical error message. Unfortunately, I think there was more to that example, but I lost my place in the PM search and haven't found it yet.

It looked something like:

my $ph = [ { alpha => 1, beta => 2, gamma => 3, delta => 4, epsilon => + 5 }, #hashref "val a", "val b", "val c", "val d", "val e" ]; + # maps to these values # Print some of the elements print $ph->[1], "\n"; print $ph->{ alpha }, "\n"; print $ph->{ epsilon }, "\n";
I'm betting that once I type this, I'll kick myself in the butt for the obvious answers that will likely ensue, especially since the message is painfully obvious that I shouldn't use that method. But I keep seeing goblins in the corner... or is that my cat stalking me? :-(

How is it that when I try to copy this method, I get that such a blatant warning, but Template.pm gets away with using it?

----
Thanks for your patience.
Prove your knowledge @ HLPD


In reply to Pseudo-hashes deprecated by SavannahLion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.