Re: [Templates] Pass through perl?

[prev] [thread] [next] [Date index for 2004/07/21]

From: Andy Wardley
Subject: Re: [Templates] Pass through perl?
Date: 07:52 on 21 Jul 2004
Chris Huegle wrote:
> [% IF 'bar' >= 'foo' %] translates to
> if ('bar' >= 'foo') { which returns true, since 1 == 1.

I think you'll find it returns true because 0 == 0.  Perl attempts to 
convert the strings to numbers and fails gracefully, returning 0 if they
don't look like numbers.

In general, if you try and compare strings with a numerical comparison 
operator, then you will get unpredictable results in both TT and Perl (and 
most other programming languages).

So don't do that.  :-)

> In PERL, you quote it: $FOO->{'gold-1'}.  You might notice in the
> examples I used below, it is quoted and 'works' in Perl.  In TT,
> FOO.'gold-1' is also invalid and there doesn't seem to be a way to quote
> it.

foo.${'gold-1'}

> You should try to stay nice when there's a chance you've misunderstood
> something.  You'll have more friends that way.

Very good advice.

A


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Pass through perl?
Chris Huegle 01:48 on 17 Jul 2004

Re: [Templates] Pass through perl?
Simon Wistow 06:21 on 17 Jul 2004

Re: [Templates] Pass through perl?
Chris Huegle 18:21 on 19 Jul 2004

Re: [Templates] Pass through perl?
Dave Howorth 11:30 on 20 Jul 2004

Re: [Templates] Pass through perl?
Chris Huegle 19:08 on 20 Jul 2004

Re: [Templates] Pass through perl?
Andy Wardley 07:52 on 21 Jul 2004

Re: [Templates] Pass through perl?
Dave Howorth 09:13 on 21 Jul 2004

Re: [Templates] Pass through perl?
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 08:59 on 05 Aug 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52