[Chicago-talk] constants and base pragma

Pete Krawczyk mongers at bsod.net
Thu Mar 16 14:05:56 PST 2006


Subject: [Chicago-talk] constants and base pragma
From: JT Smith <jt at plainblack.com>
Date: Thu, 16 Mar 2006 15:34:26 -0600

}If I do this in a non-OO manner everything works as expected. Is it not possible to 
}export constants from a base class? Is there a better way?

You can't just use BARK in that context.  Since you're inheriting, you 
need to call BARK as you would a subroutine.  You could also use $self or 
$class instead of Rover, if you're assigning them.  The following works 
for me:

}package Rover;
}
}use strict;
}use base 'Dog';
}
}sub getBark {
-     return BARK;
+     return Rover->BARK;
}}
}
}1;

$ perl -MRover -e 'print Rover->new->getBark."\n"';
1000
$

-Pete K
-- 
Pete Krawczyk
  mongers at bsod dot net





More information about the Chicago-talk mailing list