Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Exceptions vs Context Objects

by educated_foo (Vicar)
on Mar 31, 2006 at 18:17 UTC ( #540522=note: print w/replies, xml ) Need Help??


in reply to Exceptions vs Context Objects

This looks like a perfect place for the under-appreciated nonlocal loop control operators, e.g.:
@sources = ( { pre => [sub { print 1; }, sub { print 2; last pre; }, sub { prin +t 3 }], post => [sub { print 4; }, sub { print 5; last source }] }, { pre => [sub { print "badness" }] } ); source: for (@sources) { pre: for (@{$_->{pre}}) { $_->(); } post: for (@{$_->{post}}) { $_->(); } } __END__ 1 2 4 5
Document a good set of labels, and your module will be both convenient to use and educational about Perl's dark corners.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://540522]
help
Chatterbox?
[marto]: Beware the one liner :p
[Discipulus]: no, they are my crossword/sudoku like entertainment
Discipulus grins
[marto]: Even with shell command recall I find it less time consuming to do such things in a file.
[marto]: I very seldom use one liners for anything which isn't utterly trivial

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-09-22 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (260 votes). Check out past polls.

    Notices?