On Tue Nov 23 06:55:08 2004, SREZIC wrote:
Show quoted text> If SVG is imported multiple times, then a large list of warnings is
printed.
Show quoted text>
> The short sample script:
>
> #!/usr/bin/perl -w
> use SVG;
> use SVG;
>
> produces the following:
>
> Subroutine SVG::Element::hkern redefined at (eval 48) line 1.
> Subroutine SVG::Element::polyline redefined at (eval 49) line 1.
> Subroutine SVG::Element::a redefined at (eval 50) line 1.
> Subroutine SVG::Element::textPath redefined at (eval 51) line 1.
> Subroutine SVG::Element::ellipse redefined at (eval 52) line 1.
> (etc.)
>
>
This warning still exists in SVG 2.37. I suggest the following change in
SVG/Element.pm: instead
eval "sub $package\:\:$sub (\$;\@) { return
shift->tag('$tag',\@_) }";
in autoload it is probably better to write
if (!$package->can($sub)) {
no strict 'refs';
*{$package.'::'.$sub} = sub { return shift->tag($tag, @_) };
}
Note that the warning does not appear anymore because of using the ->can
method. Also, usage of string-eval is avoided here, which might be
slightly faster than the old method. Finally I removed the prototype
because it is useless when calling subs as methods.
Regards,
Slaven