If you want to override the pattern in each subclass of Thingy then the easiest thing to do is to use inheritance. Have a method that returns the pattern that you override in each subclass. Something like this:
package Thingy; sub new { my ($class, $line) = @_; my $thingy = bless {}, $class; my $pattern = $thingy->pattern; ... if ($line =~ m/$pattern/) { ... } return $thingy; } sub pattern { die "subclass should override me" }; ... package Rubber; @ISA = qw(Thingy); sub pattern { q(...) };
In reply to Re: class constants in derived classes
by adrianh
in thread class constants in derived classes
by leriksen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |