[...snip...] > > Another example: > > > > -- test.pl -- > > #!/usr/bin/perl > > my $tvar = "this is a test"; > > $tvar = undef; > > print "Tvar=$tvar\n"; > > ----------------------------------------- > > The above prints: Tvar= > > true - but only if you dont do: > > use strict; > use warnings;
i do normally always use strict :-)... and putting them (use warnings, strict) into the test.pl file above produces the same result... i do take your other points though... and i do believe that inside a loop a "row" or data should be treated as a hash... as that's what is actually is as well... but that is my opinion... would be interesting to see what Sam things... as i guess it will be his decision in the end :-) Personally though.. i have found that they way i use HTML::Template, i found found the current behaviour to be contrary to my expectations... (and hence a bug in my eyes) > > ... and I cant find a single reference suggesting to not use the 'use's. > > > > Now, so in the same context if "undef" should mean... take the outer > > scope, then perl should have ignored my "$tvar = undef" line... > > No - setting a value to 'undef' means - "remove me from the symbol table" - it > doesnt mean, "make my value to be 'undef'" (although you get this behaviour if 'use > strict' is not in effect). > > > > I think its definitely a bug :-) > > It has infact been flagged before as well... its partially on a thread > > at: > > http://www.mail-archive.com/[EMAIL PROTECTED]/msg00728.html > > although that thread digressed a bit... but this topic has been bought > > up a few times... so maybe we can find more threads about it in the > > history of the list... > > fair enough - although, that doesn't constitute a reason to modify the behaviour. A > change to the code, should require us to agree on the answer to the question(s) > posed above. > > Mathew > > > > > > > > > > > > > > > > > > thus requesting the outer global gvar to come into scope. > > > > > > Consider: > > > > > > t->param(gvar => "Global gvar"); > > > my $gvar_val; > > > my @loop; > > > for.... { > > > if (something) { > > > $gvar_val = "Loop GVar 1"; > > > } elsif (somethign else) { > > > $gvar_val = ""; > > > } > > > my $tmp; > > > $tmp->{loopvar} = ...; > > > $tmp->{gvar} = $gvar; > > > push @loop, $tmp; > > > } > > > t->param(testloop =>[EMAIL PROTECTED]); > > > > > > What would you expect the TMPL_LOOP to do in that example? > > > I would have expected that the third iteration to use the global gvar value. > > > > > > Mathew > > > > > > > > > > ======================================================================== > > > > test.tmpl: > > > > ---------- > > > > Global Variable gvar is: <tmpl_var name=gvar> > > > > > > > > Loop: <tmpl_loop name=testloop> > > > > loopvar: <tmpl_var name=loopvar> > > > > gvar : <tmpl_var name=gvar> > > > > </tmpl_loop> > > > > ======================================================================== > > > > test.pl > > > > ------- > > > > > > > > use strict; > > > > use HTML::Template; > > > > > > > > my $t = new HTML::Template(filename => "test.tmpl", global_vars => 1,) > > > > || die; > > > > > > > > my $testloop = [ > > > > { loopvar => "GVar should be set", gvar => "Loop GVar 1" }, > > > > { loopvar => "GVar should be blank", gvar => "" }, > > > > { loopvar => "GVar should be blank again", gvar => undef }, > > > > ]; > > > > > > > > $t->param(gvar => "global variable"); > > > > $t->param(testloop => $testloop); > > > > print $t->output(); > > > > ======================================================================== > > > > > > > > When you run test.pl.. you get the following output: > > > > ------------------------------------------------------------------------ > > > > Global Variable gvar is: global variable > > > > > > > > Loop: > > > > loopvar: GVar should be set > > > > gvar : Loop GVar 1 > > > > > > > > loopvar: GVar should be blank > > > > gvar : > > > > > > > > loopvar: GVar should be blank again > > > > gvar : global variable > > > > ------------------------------------------------------------------------ > > > > > > > > Now, the issue is that "gvar" in the third iteration of the loop, > > > > "should have been blank"... i explicitely set it to "undef" in the > > > > code.. however, since global_vars was on, it ignored my "undef". > > > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id%62&alloc_ida84&op=click > _______________________________________________ > Html-template-users mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/html-template-users ------------------------------------------------------- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users