[Templates] "in array" function?

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Thu Mar 6 10:50:08 GMT 2008


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;
      return (any(@_) eq $str);
  }

TMTOWTDI :)
Dave



More information about the templates mailing list