-----BEGIN PGP SIGNED MESSAGE-----

Moin,

the sequel to the world-known[0] series:

This time Attribute::Handlers gets a treatment. I also fixed one instance 
in the docs, since the shown code does not compile if not 
something/someone loaded Carp before.

All tests pass:

        All tests successful.
        u=2.74  s=0.81  cu=186.77  cs=25.45  scripts=954  tests=107891

One more comment:

What is with the files in /lib/Attribute/Handlers/demo? Won't these get 
accidentily installed?

Best wishes,

Tels

[0] Thanx to Google.

- -- 
 Signed on Sun Jun 26 11:14:40 2005 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "My glasses, my glasses. I cannot see without my glasses." - "My
 glasses, my glasses. I cannot be seen without my glasses."

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQr6CFHcLPEOTuEwVAQHUaAf+OEqsvXx6M6k+Ki8zDI/EPHW0Dqg/e7TH
hMEKT/F3ezoMFDecP5eGtmbUHwXr+zGAtOy9nEGuhw/H7q1Cshk0hg8S4GIDwAn6
gv3P9i/O49rB7UwM9+wBThL1oIMoVB65NffZpDpxaxAxHDoePtlbxls2WOjQZKf0
LHsoT4H9pLMz5WUHEeirYwXppEvd9rHM39v2aveMnD+YEgm7cAvAAHu1Msv0EK69
oqCTvEUukflxrbsWKCGY5I3mTcI+c92+YHRpQzWhZ3mHk1rfpN0QQ82KjCc+tGpg
VZ6oj7Hmn8uGnCVo4L/2MGmU0ya2qShTkQy1Du4qhWHEPVsmHZ5RIg==
=cSpn
-----END PGP SIGNATURE-----
diff -ruN blead.patch.2/lib/Attribute/Handlers.pm 
blead.patch.3/lib/Attribute/Handlers.pm
--- blead.patch.2/lib/Attribute/Handlers.pm     2004-02-25 02:55:24.000000000 
+0100
+++ blead.patch.3/lib/Attribute/Handlers.pm     2005-06-26 12:05:52.000000000 
+0200
@@ -1,8 +1,7 @@
 package Attribute::Handlers;
 use 5.006;
-use Carp;
 use warnings;
-$VERSION = '0.78_01';
+$VERSION = '0.78_02';
 # $DB::single=1;
 
 my %symcache;
@@ -40,8 +39,18 @@
 );
 my @global_phases = qw(BEGIN CHECK INIT END);
 
+sub croak {
+       require Carp;
+       goto &Carp::croak;
+}
+
+sub carp {
+       require Carp;
+       goto &Carp::carp;
+}
+
 sub _usage_AH_ {
-       croak "Usage: use $_[0] autotie => {AttrName => TieClassName,...}";
+       croak ("Usage: use $_[0] autotie => {AttrName => TieClassName,...}");
 }
 
 my $qual_id = qr/^[_a-z]\w*(::[_a-z]\w*)*$/i;
@@ -82,7 +91,7 @@
            }
         }
         else {
-            croak "Can't understand $_"; 
+            croak ("Can't understand $_");
         }
     }
 }
@@ -102,8 +111,8 @@
 sub AUTOLOAD {
        my ($class) = $AUTOLOAD =~ m/(.*)::/g;
        $AUTOLOAD =~ m/_ATTR_(.*?)_(.*)/ or
-           croak "Can't locate class method '$AUTOLOAD' via package '$class'";
-       croak "Attribute handler '$2' doesn't handle $1 attributes";
+           croak ("Can't locate class method '$AUTOLOAD' via package 
'$class'");
+       croak ("Attribute handler '$2' doesn't handle $1 attributes");
 }
 
 sub DESTROY {}
@@ -130,9 +139,9 @@
                                || ! keys %{$phase{$ref}};
                        # Added for cleanup to not pollute next call.
                        (%lastattr = ()),
-                       croak "Can't have two ATTR specifiers on one subroutine"
+                       croak ("Can't have two ATTR specifiers on one 
subroutine")
                                if keys %lastattr;
-                       croak "Bad attribute type: ATTR($data)"
+                       croak ("Bad attribute type: ATTR($data)")
                                unless $validtype{$data};
                        %lastattr=(pkg=>$pkg,ref=>$ref,type=>$data);
                }
@@ -150,9 +159,10 @@
                                # if _gen_handler_AH_ is being called after 
                                # CHECK it's for a lexical, so make sure
                                # it didn't want to run anything later
-                       
+
+                               require Carp;                   
                                local $Carp::CarpLevel = 2;
-                               carp "Won't be able to apply END handler"
+                               carp ("Won't be able to apply END handler")
                                        if $phase{$handler}{END};
                        }
                        else {
@@ -453,7 +463,7 @@
         sub RealLoud :ATTR(SCALAR) { print "Yeeeeow!" }
         sub RealLoud :ATTR(ARRAY) { print "Urrrrrrrrrr!" }
         sub RealLoud :ATTR(HASH) { print "Arrrrrgggghhhhhh!" }
-        sub RealLoud :ATTR(CODE) { croak "Real loud sub torpedoed" }
+        sub RealLoud :ATTR(CODE) { require Carp; Carp::croak ("Real loud sub 
torpedoed") }
 
 You can also explicitly indicate that a single handler is meant to be
 used for all types of referents like so:

Reply via email to