http://www.perlmonks.org?node_id=771218


in reply to Re^2: Using closures to achieve data hiding in OO Perl
in thread Using closures to achieve data hiding in OO Perl

I use closures all the time. But never explicitly for data hiding (although it can come as a byproduct). Closures especially when coupled with eval, makes for an extremely powerful approach to solving problems, optimizing, simplifying design, and providing encapsulation. Using closures you can basically avoid OO, and do things that are extremely inefficient to do via OO techniques (especially in perl where method calls are slow). In fact I'd argue that closures are generally speaking more useful than OO.

Go and get yourself a copy of Higher Order Perl by dominus. Its one of the better Perl books out there, and its almost all about using closures.

Note: I updated this node by changing the previous link to mjd to the correct dominus.

---
$world=~s/war/peace/g

  • Comment on Re^3: Using closures to achieve data hiding in OO Perl

Replies are listed 'Best First'.
Re^4: Using closures to achieve data hiding in OO Perl
by saurabh.hirani (Beadle) on Jun 15, 2009 at 04:45 UTC
    Go and get yourself a copy of Higher Order Perl by dominus. Its one of the better Perl books out there, and its almost all about using closures.

    Thanks for the link. It looks interesting. Will definitely read it.

      Dont thank me for linking to it, thank dominus for writing it. Writing perl books is really really hard, and he did an absolutely outstanding job on it. Additionally if you ever get a chance to attend any kind of talk, or workshop or lecture or even just a beer with him then take it. It will definitely be worth it. He also has an excellent set of online resources: perl.plover.com

      ---
      $world=~s/war/peace/g