Sub::Approx::Subclass (was Re: Grep here yet?)

Mark Fowler mark at profero.com
Mon Oct 2 03:11:11 CDT 2000


> p.s. Mark, I think I've got a solution to your Sub::Approx::Subclass 
> problems. Haven't had time to investigate it this weekend, but I'll try it 
> out tomorrow and get back to you.

I had a little think about that this weekend while I was moving boxes o'
stuff around London and I came up with this (perverted) way of doing
things....

You have three (3) classes.  Sub::Approx, Sub::Approx::Subclass, and
Sub::Approx::Subclass::Matchers.  Note that I haven't actually tried this
yet...

The first file is :

package Sub::Approx::Subclass::Matchers;

sub matchers
{
 my $this = shift;
 my @hash = $this->SUPER::matchers;
 push @hash, "whatever" => [\&setup_whatever,&match_whatever];
 return @hash
}

1;

package Sub::Approx::Subclass;
use base qw(Sub::Approx::Subclass::Matchers Sub::Approx);

1;

-----

You'll also need to make a few changes to Sub::Approx, namely that you
replace line 44 to read 

 my %funcs = $class->matches;
 
And make a subroutine that does

sub matches
{
 (text_soundex  =>  [\&setup_text_soundex,
                     \&match_text_soundex,
 text_metaphone =>  [\&setup_text_metaphone,
                     \&match_text_metaphone],
 string_approx  =>  [\&setup_string_approx,
                     \&match_string_approx])
}

Not sure if this will work or not....

Later.

Mark

-- 
print "\n",map{my$a="\n"if(length$_>6);' 'x(36-length($_)/2)."$_\n$a"} (
   Name  => 'Mark Fowler',        Title => 'Technology Developer'      ,
   Firm  => 'Profero Ltd',        Web   => 'http://www.profero.com/'   ,
   Email => 'mark at profero.com',   Phone => '+44 (0) 20 7700 9960'      )








More information about the Bath-pm mailing list