I realize that it's somewhat un-perl, but is there a way to do "in"
within TT? It would be nice to keep things clean when I have large
lists of things I'm comparing a single variable to in an if-statement.
[% IF var == 'foo' || var == 'bar' %]
I've tried to use something like:
[% IF [ 'foo'
Chris Petersen wrote:
> I realize that it's somewhat un-perl, but is there a way to do "in"
> within TT? It would be nice to keep things clean when I have large
> lists of things I'm comparing a single variable to in an if-statement.
>
> [% IF var == 'foo' || var == 'bar' %]
>
> I've tried t
>How about [% IF foo.match('(foo|bar)') %] ?
And of course by foo.match I meant var.match.
--
Drew Marold - [EMAIL PROTECTED]
Perl programmer, bass player, luthier, Gentleman Adventurer
Photography: http://www.flickr.com/photos/unstoppabledrew/
Nothing looks worse on your outdoors resume than
How about [% IF foo.match('(foo|bar)') %] ?
Drew
Chris Petersen wrote:
> I realize that it's somewhat un-perl, but is there a way to do "in"
> within TT? It would be nice to keep things clean when I have large
> lists of things I'm comparing a single variable to in an if-statement.
>
On Mar 5, 2008, at 12:40 PM, Andrew Marold wrote:
> How about [% IF foo.match('(foo|bar)') %] ?
That would work, assuming you added anchors to the regex and I'm only
ever matching against static lists and not pre-defined variables
(which in this case is the likely scenario).. but would also r
On Wed, Mar 5, 2008 at 2:46 PM, Chris Petersen <[EMAIL PROTECTED]>
wrote:
> On Mar 5, 2008, at 12:40 PM, Andrew Marold wrote:
> > How about [% IF foo.match('(foo|bar)') %] ?
>
> That would work, assuming you added anchors to the regex and I'm only
> ever matching against static lists and not pre-d
Dave Howorth wrote:
> Sean McAfee wrote:
>
>> $Template::Stash::SCALAR_OPS->{isOneOf} = sub {
>> my $str = shift;
>> $str eq $_ and return 1 for @_;
>> return 0;
>> };
>>
>
> Or for added pzazz, something like:
>
> use Perl6::Junction qw/ any /;
>
> $Template::Stash::SCALAR_
Sean McAfee wrote:
> $Template::Stash::SCALAR_OPS->{isOneOf} = sub {
> my $str = shift;
> $str eq $_ and return 1 for @_;
> return 0;
> };
Or for added pzazz, something like:
use Perl6::Junction qw/ any /;
$Template::Stash::SCALAR_OPS->{isOneOf} = sub {
my $str = shift;
Slaven Rezic wrote:
> Dave Howorth wrote:
>
>> Sean McAfee wrote:
>>
>>
>>> $Template::Stash::SCALAR_OPS->{isOneOf} = sub {
>>> my $str = shift;
>>> $str eq $_ and return 1 for @_;
>>> return 0;
>>> };
>>>
>>>
>> Or for added pzazz, something like:
>>
>> use Per
Mark Mills wrote:
> Slaven Rezic wrote:
>> Dave Howorth wrote:
>>
>>> Sean McAfee wrote:
>>>
$Template::Stash::SCALAR_OPS->{isOneOf} = sub {
my $str = shift;
$str eq $_ and return 1 for @_;
return 0;
};
>>> Or for added pzazz, something l
10 matches
Mail list logo