[ic] Trying to define a new filter

Mike Heins mikeh@minivend.com
Sat, 14 Apr 2001 05:05:32 -0400


Quoting Jonathan Clark (jonc@webmaint.com):
> [ic 4.6.4 / RH6.2]
> 
> Hi All,
> 
> I am trying to define a new filter in a GlobalSub in interchange.cfg.
> As per the
> I have:
> 
> GlobalSub <<EOR
> sub new_filter {
>         package Vend::Interpolate;
>         $Filter{reverse} = sub { $val = shift; return scalar reverse
> val  };
> }
> EOR

Looks like just a Perl problem -- you must use strict (i.e. my $val)
and reference $val instead of val in your call. Also, you must have
that in a BEGIN block to pick it up, otherwise you will have to
call the globalsub before it is defined.

GlobalSub <<EOR
sub new_filter {
    BEGIN {
	package Vend::Interpolate;
	$Filter{reverse} = sub {
			    my $val = shift;
			    return scalar reverse $val;
			    };
    }
}
EOR

-- 
Red Hat, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <mheins@redhat.com>

For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled. -- Dick Feynman