leriksen has asked for the wisdom of the Perl Monks concerning the following question:
in file Thingy.pm
package Thingy; sub new { my ($class, $line) = @_; my $thingy = {}; ... if ($line =~ m/$PATTERN/) { ... } bless $thingy, $class; } 1;
in file Rubber.pm
package Rubber; @ISA = qw(Thingy); use vars $PATTERN = q(...); 1;
and later in the main script
use Rubber; my $line = ...; my $thing = Rubber->new($line);
but I always get 'use of unitialised value in regex compilation...'
Trying $class::PATTERN doesn't work either.
What am I doing wrong - how do I reference the constant in derived classs Rubber from the method in base class Thingy?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: class constants in derived classes
by adrianh (Chancellor) on Apr 03, 2003 at 09:46 UTC | |
by leriksen (Curate) on Apr 03, 2003 at 23:18 UTC | |
by adrianh (Chancellor) on Apr 04, 2003 at 08:49 UTC | |
by leriksen (Curate) on Apr 07, 2003 at 06:19 UTC | |
by adrianh (Chancellor) on Apr 07, 2003 at 09:42 UTC | |
|
Re: class constants in derived classes
by broquaint (Abbot) on Apr 03, 2003 at 08:40 UTC | |
|
Re: class constants in derived classes
by Joost (Canon) on Apr 03, 2003 at 10:03 UTC | |
|
•Re: class constants in derived classes
by merlyn (Sage) on Apr 03, 2003 at 13:56 UTC | |
by leriksen (Curate) on Apr 03, 2003 at 23:19 UTC |