Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found