Skip Menu |

This queue is for tickets about the SVG CPAN distribution.

Report information
The Basics
Id: 8574
Status: resolved
Priority: 0/
Queue: SVG

People
Owner: ronan [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.32
Fixed in: (no value)



Subject: Warnings if SVG is used multiple times
If SVG is imported multiple times, then a large list of warnings is printed. 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.) Regards, Slaven
From: SREZIC [...] cpan.org
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
Thanks for the patience. I've implemented and tested your suggestion. Ronan
Thanks for the patience. I've implemented and tested your suggestion. Ronan