develooper Front page | perl.perl5.porters | Postings from March 2006

Re: Multiple Perl version support quandary

Thread Previous | Thread Next
From:
John Peacock
Date:
March 27, 2006 10:07
Subject:
Re: Multiple Perl version support quandary
Message ID:
442829F4.70005@rowman.com
Nick Ing-Simmons wrote:
> use looks for %INC entry to see if it is already loaded

Ah ha!  That's the ticket.  For future references, this is the block of 
code that I added (watch wrapping):

+BEGIN {
+    # Perl 5.005_x doesn't support lexical warnings, so we
+    # do the next best thing and mess with the global $SIG{__WARN__}
+    # handler to hide the "mandatory" warnings
+    if ( $] < 5.006 ) {
+       my $warnings = <<"";
+    package warnings;
+    # this evil^Wclever bit courtesy of Nick Ing-Simmons
+    \$INC{'warnings.pm'} = "inline";
+    sub unimport {
+       shift; # ignore the package name
+       my \@warnings = \@_;
+       my \$warnregex = '('.join('|',\@warnings).')';
+       \$SIG{__WARN__} = sub { warn \$_[0] unless \$_[0] =~ 
/\$warnregex/ };
+    }
+    1;
+
+       eval $warnings;
+       die $@ if $@;
+    }
+}
+

version-0.58 heading to a CPAN mirror near you (no substantive changes 
since 0.57, just a compatibility release).

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748

Thread Previous | Thread Next


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