This does not seem to work.

The GD:: namespace is not copying over... The Hackmare::GD namespace is getting pointed to the GD::Image namespace when the GD::Image copy takes place. I tried both:

*Hackmare::GD::Image::new = \&GD::Image::new; and *Hackmare::GD::Image:: = GD::Image::;
. Here is the debug output if it helps at all...
*Hackmare::GD::Image::new = \&GD::Image::new; *GD::Image:: = *SVG::GD::Image::; package SVG::GD::Image; #constructor sub SVG::GD::Image::new { my $class = shift; my $self = {}; bless $self, $class; $self->{_GD_} = new Hackmare::GD::Image(@_) || print STDERR "Quitting. Unable to construct new GD::Image object using GD: $!\n"; ....stuff.... return $self }
Here is the debugging info: Notice the infinite loop for the constructor:
main::(test/18-loadsvggd.pl:6): print "Creating an SVG::GD Image\n"; DB<0> Creating an SVG::GD Image main::(test/18-loadsvggd.pl:7): my ($width,$height) = (200,200); DB<0> main::(test/18-loadsvggd.pl:8): my $dwg = new GD::Image($width,$height +); DB<0> s SVG::GD::Image::new(SVG/GD.pm:79): my $class = shift; DB<0> s SVG::GD::Image::new(SVG/GD.pm:80): my $self = {}; DB<0> SVG::GD::Image::new(SVG/GD.pm:81): bless $self, $class; DB<0> SVG::GD::Image::new(SVG/GD.pm:82): $self->{_GD_} = new Hackma +re::GD::Image(@_) SVG::GD::Image::new(SVG/GD.pm:83): || print STDERR " +Quitting. Unable to construct new GD::Image SVG::GD::Image::new(SVG/GD.pm:84): object using GD: $!\n" +; DB<0> s GD::Image::new(SVG/GD.pm:79): my $class = shift; DB<0> GD::Image::new(SVG/GD.pm:80): my $self = {}; DB<0> GD::Image::new(SVG/GD.pm:81): bless $self, $class; DB<0> GD::Image::new(SVG/GD.pm:82): $self->{_GD_} = new Hackmare:: +GD::Image(@_) GD::Image::new(SVG/GD.pm:83): || print STDERR "Quitt +ing. Unable to construct new GD::Image GD::Image::new(SVG/GD.pm:84): object using GD: $!\n"; DB<0> GD::Image::new(SVG/GD.pm:79): my $class = shift; DB<0> GD::Image::new(SVG/GD.pm:80): my $self = {}; DB<0> GD::Image::new(SVG/GD.pm:81): bless $self, $class;
Is anything glaringly obvious here?

hackmare.

In reply to Re: Re: Re: Re: hijacking a module constructor by hackmare
in thread hijacking a module constructor by hackmare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.