Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

rovf's scratchpad

by rovf (Priest)
on May 15, 2008 at 15:53 UTC ( [id://686764]=scratchpad: print w/replies, xml ) Need Help??

What you have to do to use Attribute::Default from CPAN, if you want to use it in a module which also uses the Exporter.

package Example; use strict; use warnings; # (1) Access the Exporter in the following way. # - with 'use', not 'require' or 'use base "..."'. # - qw(import) # - do NOT fiddle around with @ISA use Exporter qw(import); # (2) Access Attribute::Default with use base, not with # use Attribute::Default; # (This is the documented way anyway) use base 'Attribute::Default'; our @EXPORT=qw(foo bar); our @EXPORT_OK=qw(baz); # subs which you are only using within this package, # you can define as documented in the perldoc for # Attribute::Default, but DO NOT USE PROTOTYPES. # For those subs however, which are exported, # you have to use the following trick. Let's assume # that foo is supposed to have the signature # sub foo($;$$) # and that the default values for the missing arguments # are 'hanky' and 'panky'. Then do it like this: sub foo($;$$) { &_foo } # of course you don't HAVE # to write the prototype sub _foo : Default('hanky','panky') # but no proto here! { ... }

Using the Chatterbox: URLs, Special Characters, and Code
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2025-05-17 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.