Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Short Refactoring Tip: let the object do it for you

by hardburn (Abbot)
on May 20, 2003 at 03:11 UTC ( #259349=note: print w/replies, xml ) Need Help??


in reply to Re: Short Refactoring Tip: let the object do it for you
in thread Short Refactoring Tip: let the object do it for you

I'd probably work that out as a dispatch table instead:

my %STATES = ( sent => sub { . . . }, pending => sub { . . . }, waiting => sub { . . . }, procrastinating => sub { . . . }, delayed => sub { . . . }, ); # Make 'pending' and 'waiting' the same thing $STATES{pending} = $STATES{waiting}; # Later $STATES{$status->state->name}->();

It's faster than a speeding regex. And I personally think dispatch tables are sexy.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://259349]
help
Chatterbox?
[Cosmic37]: sort of anyway... hurls some peaches... :-D
[Cosmic37]: when slurping one can undef the record separator thingy; but presumably one should redefine it afterwards? how?
[Cosmic37]: I'm wondering whether there is a specific/(or at least "usual") command or does one take a copy before undefining and then copy it back after slurping file into a string?
[BarApp]: I need help accessing perl files. I need permission!!!

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-06-29 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (672 votes). Check out past polls.