Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

RE: RE: RE (tilly) 2: access to my variables from other subs

by chromatic (Archbishop)
on Oct 21, 2000 at 09:08 UTC ( [id://37781]=note: print w/replies, xml ) Need Help??


in reply to RE: RE (tilly) 2: access to my variables from other subs
in thread access to my variables from other subs

In a similar situation, I'd use an object. If you need to carry context and variables around, blessing a hash is a pretty convenient way to have a bundle of data that knows which operations it supports.

The beauty there is, depending on your encapsulation paranoia, you still have access to the hash through the reference, so working with its data is as easy as usual.

Nesting subroutines is a conceptual no-no in Perl... hard to maintain, hard to debug. The closures route is a little tricky if you're not familiar with functional programming (but can be very useful in other cases).

If you can live with enforced lexical context through a reference, you'll be a lot happier with objects.

  • Comment on RE: RE: RE (tilly) 2: access to my variables from other subs

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-25 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found