OC-PM: EasySlice and Source Filters?
Wilson, Douglas
dgwilson at sonomasystems.net
Fri Jan 10 11:52:10 CST 2003
Typo in that last one...
One should never edit after cutting and pasting... :-)
package MethodFilter;
#
# Use methods with a single colon
# (":") character in them
# as bare words.
# Author: Douglas Wilson
#
# E.g. Package->foo:bar;
# creates package variable $MethodFilter::_foo_bar,
# sets it to 'foo:bar', and substitutes the variable name
# into the method call
#
# Known issues:
# 1) $condtion ? $obj->method:function();
# (just put white space around the ":" to fix it)
# 2) single quoted strings containing, e.g., '->word:word'
# (break up the string: '->' . 'word:word')
# 3) Line break after method operator '->'
# (break the line before the '->')
#
use strict;
use warnings;
use Filter::Util::Call;
use vars qw($tmp);
sub import {
filter_add(
sub {
my ($status);
s/
(?<=->)((\w+):(\w+))
(?{
no strict 'refs';
$tmp = __PACKAGE__ . "::_${2}_${3}";
$$tmp = $1;
})
/\$$tmp/gx if ($status = filter_read()) > 0;
$status;
}
);
}
1;
More information about the Oc-pm
mailing list