Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Subroutine attributes for solving crosscutting problems

by bennymack (Pilgrim)
on Sep 08, 2006 at 00:58 UTC ( [id://571838]=note: print w/replies, xml ) Need Help??


in reply to Subroutine attributes for solving crosscutting problems

That's a neat way to do it. I've been kicking around the idea of using attributes in some of my programming but just haven't found a situation where they're the best solution yet.

It's not demonstrated in your example here but something that would be a nice additional feature would be to allow compile time enabling/disabling of the effects of the attribute. In this case, logging.

Ideally this could be used as a way to turn logging on and off based on some condition or configuration so the transition from development to production would require no code changes logging wise.

Lastly, I don't think you need to shift $self then hand it back to the code ref call. Just do $code->( @_ ) with the whole stack.

  • Comment on Re: Subroutine attributes for solving crosscutting problems

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://571838]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-23 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found