Re: [htmltmpl] Patch to fix global_vars and loop problem...
Brought to you by:
samtregar
From: Mathew R. <mat...@re...> - 2004-05-13 22:49:54
|
good example -> given this , I would agreee that it is a bug. ... and yes you are correct, the stderr message is generated by 'use = warnings' not 'use strict'. Mathew > > Relating this to TMPL_LOOP's... the question becomes, "Is a variable = inside=20 > > a loop considered to be equivalent to a hash key, or equivalent to a = > > variable?", alternatively it could be asked "What is the = 'strict'ness of=20 > > TMPL_LOOP variables (as compared to Perl's use of 'strict'ness)?". > > =20 >=20 > According to the H::T docs ... > "For the computer-science geeks among you, a <TMPL_LOOP> introduces a = new > scope much like a perl subroutine call." > So the scope (when global vars is turned on) is that it should behave = like a > variable, not a hash (since it is a TMPL_VAR not a TMPL_KEY right :). = For > instance, the following simple script.. >=20 > #!/usr/bin/perl > use strict; > = =20 > = =20 > our $var =3D 'a test'; > &test(); > = =20 > = =20 > sub test > { > my $var =3D 'another test'; > $var =3D undef; > print "This is $var\n"; > } >=20 > produces this output > 'This is' >=20 > Even with 'use strict' (and even with 'use warnings' STDOUT still gets = this > output even if STDERR get's the warning). >=20 > So, in my opinion he is right. This is a bug. And I even think sam = admitted it > was and that somehow what was needed was to check 'exists' and not = truthfulness. >=20 >=20 > > Since we are talking about TMPL_LOOP variables, not Perl hash keys, = it gets > back to the question(s) posed above. > >=20 > > > Another example: > > >=20 > > > -- test.pl -- > > > #!/usr/bin/perl > > > my $tvar =3D "this is a test"; > > > $tvar =3D undef; > > > print "Tvar=3D$tvar\n"; > > > ----------------------------------------- > > > The above prints: Tvar=3D > >=20 > > true - but only if you dont do: > >=20 > > use strict; > > use warnings; >=20 > Even if you 'use strict' and 'use warnings' you get the right output = (like I > said before, on STDOUT even if you do get a 'warning' on STDERR) >=20 >=20 > Michael Peters > Venzia >=20 >=20 > ------------------------------------------------------- > 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=3D2562&alloc_id=3D6184&op=3Dclick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |