develooper Front page | perl.perl5.porters | Postings from April 2000

Weird 'use base ...' effect of "static link"

From:
Nick Ing-Simmons
Date:
April 29, 2000 07:50
Subject:
Weird 'use base ...' effect of "static link"
Message ID:
E12lYa4-0003xM-00@mserv1b.u-net.net

Debugging my "convert script to executable" scheme has shown up 
another oddity of 5.005_03's 'base.pm'

If you have (say)

use base qw(Tk::Text);

Then you hit base.pm:

package base;

sub import {
    my $class = shift;
    my $fields_base;

    foreach my $base (@_) {
	unless (defined %{"$base\::"}) {
	    eval "require $base";


Now leaving aside that that is using defined on a hash - which is 
alleged to be pointless - to see if package exists. The existance test 
seems to work in this case.

If Tk::Text is Dynamic linked and not yet loaded the require happens
as I expected. 

BUT - if you have statically linked Tk::Text (using 
ExtUtils::Miniperl to build a perlmain) then there has been 
a newXS("Tk::Text::bootstrap",...) at xs_init time and so "stash" 
exists and require does not happen so perl part of Tk::Text package
is never created. What fun :-}

5.6.0's base.pm does not have the problem.



-- 
Nick Ing-Simmons




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About