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