Re: pushing value to $t->src



After quite a bit of poking around in the script, I actually got it to work, well 99.9% anyway.

$t->number_in( $number_in );

Going by some other pages I have, I understood the above line to mean that ->number_in will be replaced by the value in $number_in.
However, when the page hits the browser, what was __number_in__ in the template is now empty.
Instead of <title>__number_in__</title> becoming <title>6</title>
it is becoming <title></title>

I know that my code is a mess, but it works. (with 1 exception ofcourse)

#! c:\perl\bin\perl.exe -T
use warnings;
#use strict;


use CGI qw/:all/;

use CGI::Carp qw/fatalsToBrowser/;

use HTMLTMPL;

my $t = HTMLTMPL->new();

{

$number_in = 6;

$string1 = abcdef;
$string2 = ghijkl;
$string3 = mnopqr;
$string4 = stuvwx;


$number_out = $number_in;

while ($number_out > 24) {$number_out -= 24;}

if (($number_out > 0) && ($number_out <= 6)) {$string = $string1;}
if (($number_out > 6) && ($number_out <= 12)) {$number_out -= 6;$string = $string2;}
if (($number_out > 12) && ($number_out <= 18)) {$number_out -= 12;$string = $string3;}
if (($number_out > 18) && ($number_out <= 24)) {$number_out -= 18;$string = $string4;}


$ZZZZ = substr $string, $number_out-1, 1;

}

$t->src( "c:/apache2/htdocs/testing/testing123/$ZZZZ.html" );
$t->number_in( $number_in ); # <----- not doing it properly

$t->output( CGI::header );
.



Relevant Pages

  • inserting a newline character in a bash (or sh) shell
    ... I've been looking for a way to do this in a fancy grep script I'm developing ... However the newline insertion doesn't work and I get something like: ...
    (comp.unix.shell)
  • Re: dynamic variable names or using a variable as anothers name
    ... stringD which are all associated with string1 and stringA. ... That sounds like a hash where each value is a hash where each value is ... the value is an array containing stringB,stringC,stringD. ... to access it in various places during a single run of the script, ...
    (comp.lang.ruby)
  • Re: Replacing multi-line expression
    ... Script started on Thu 27 May 2010 20:20:56 BST ... $ cat eg ... Basically the jump can be removed, or it can be to the end of the script. ...
    (comp.unix.shell)