Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Greetings,
Though there are many things that could be suggested about your code the most important is to adopt the use of strict and warnings.
Other than that I get the feeling you have not provided all of the relevant code in the example you give.

For instance where do %loop_data and $loop_data get initialized? What is suppose to happen to ($name,$value) in your
foreach $line (@allow_edit){ .... }
block?
I think I follow what you are attempting up until you close your filehandles... Then things get murky.

Empirically @loop will never hold anything since you never fill it. Your #fill in the loop, foreach block creates and fills in $name and $value that fall out of scope with each iteration, @loop is never involved.
Now if I follow your intent, and this is a big stretch to say the least, here is my suggestion for what I think you are shooting for (However not having seen your HTML template its a guess at best).

Untested mind you.
my @loop; #fill in the array @loop with hash references from @allow_edit... foreach (@allow_edit){ my($name, $value) = split /=/,$_; push @loop, {$name=>$value}; }
Then continue with your template calls.
It would be helpful to see what the markup (HTML) looks like that you are filling with "loop" in your $template->param call.
without that everything is simply a shot in the dark.


Update
Okay, thats definitely helpful.
So given the code.
<!-- start of loop --> <TMPL_LOOP NAME="loop"> <tr> <td align="right"><TMPL_VAR NAME="part1"></td> <td><INPUT TYPE=text NAME="<TMPL_VAR NAME="par +t1">" VALUE="<TMPL_VAR NAME="part2">"></td> </tr> </TMPL_LOOP> <!-- end of loop -->
I am lead to think you would like $name to appear in "part1" and $value to appear in "part2". Am I getting warmer?
Lets modify the loop I suggested earlier to accomplish this.
my @loop; #fill in the array @loop with hash references from @allow_edit... foreach (@allow_edit){ my($name, $value) = split /=/,$_; push @loop, {part1=>$name, part2=>$value}; }
That should do it. I hope that helps.
And one more thing, have a look at the range operators for another way to handle your file partitioning.

-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

In reply to Re: Populating an HTML Template by injunjoel
in thread Populating an HTML Template by hmag

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (8)
    As of 2020-10-20 21:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favourite web site is:












      Results (210 votes). Check out past polls.

      Notices?