I am trying to turn a repetitive assignment into a loop for HTML::Template (a Perl loop, not an HTML::Template Loop). I'm given a series of scalars (three shown below) and I have commented out the $tmpl->param calls (also below, which worked fine). I intended the foreach loop to replace the long list of calls, but it didn't work, nor did several variations I tried. Most of the variations died with the error that a scalar was found when an operator was expected. The variation below plugged into the template the literal '$student_id' instead of its value' trip304.' I've run out of ideas to try and books to look in. Anyone's advice would be most welcome!

$student_id = "trip304";
$name_full = "John Smith";
$name_nick = "Johnny";
. . .
# Assign template parameters
foreach (@info_prams) {
        $tmpl->param( $_ => ("\$$_") );
}
#$tmpl->param( student_id    => $student_id               );
#$tmpl->param( name_full     => $name_full                );
#$tmpl->param( name_nick     => $name_nick                );
. . .


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to