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

[PATCH] Fatal v1.03

Thread Next
Jerrad Pierce
December 10, 2006 11:38
[PATCH] Fatal v1.03
Message ID:
Below is a patch for the Fatal module, part of the core distribution.
There are two usability problems with the current code, and the patch
fixes one of them.

As it stands the code will only let you Fatal-ize CORE functions or
subroutines in the caller's namespace. It seems perfectly reasonable
to me that a careful author might like to be able to infect another
package with Fatal tersely and explicitly

	package main;
	import Fatal 'Foo::bar';

rather than verbosely and implicitly

	package main;
	  package Foo;
	  import Fatal 'bar';

And secondly, that one might light to Fatal-ize CORE modules globally.
The patch address this second problem, allowing:

	import Fatal 'CORE::GLOBAL::open';

Although it does so with a minimal patch, and another means of doing so
to accept the briefer syntax (GLOBAL_open) used in perlsub might be nice.

--- /afs/	Fri Jun  4 02:46:51 2004
+++ /afs/	Sun Dec 10 14:11:43 2006
@@ -5,7 +5,7 @@
 use strict;
 our($AUTOLOAD, $Debug, $VERSION);
-$VERSION = 1.03;
+$VERSION = 1.04;
 $Debug = 0 unless defined $Debug;
@@ -99,7 +99,7 @@
 	$sref = \&$sub;
 	$proto = prototype $sref;
 	$call = '&$sref';
-    } elsif ($sub eq $ini) {	# Stray user subroutine
+    } elsif ($sub eq $ini && $sub !~ /^CORE::GLOBAL/ ) {	# Stray user subroutine
 	die "$sub is not a Perl subroutine" 
     } else {			# CORE subroutine
         $proto = eval { prototype "CORE::$name" };

P.S. Author is not susbscribed to p5p
Free map of local environmental resources:
MOTD on Prickle-Prickle, the 52nd of The Aftermath, in the YOLD 3172:
Any damn fool can making sweeping generalizations about damn fools.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About