Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Mapping URLs to code - in search of perlish dispatch schemes

by jaa (Friar)
on Jul 21, 2006 at 09:47 UTC ( [id://562825]=note: print w/replies, xml ) Need Help??


in reply to Mapping URLs to code - in search of perlish dispatch schemes

I am coming to like this URL matching even more... :) are there any polymorphic lessons to be learnt from other OO languages that might help?

Another thought springs to mind - is there a place for a hierarchy in your interface? It might also assist in despatch efficiency, or even just remind the using programmer to consider despatch efficiency. I don't know if it would have any relevance to handling multi- matching despatches - maybe this is how you specify a multi-despatch?

# flat /edit?name=(\w+);city=(\w+);... { $r->print "Edit '$name' in '$city'"; }; /edit?name=(\w+);job=(.*);... { $r->print "Edit '$name' who does '$job'"; }; # hierarchical1 /edit => [ name=(\w+);city=(\w+);... { $r->print "Edit '$name' in '$city'"; }, name=(\w+);job=(.*);... { $r->print "Edit '$name' who does '$job'"; }, ] # hierarchical2 /edit => [ name=(\w+);... => [ city=(\w+);... { $r->print "Edit '$name' in '$city'"; }, job=(.*);... { $r->print "Edit '$name' who does '$job'"; }, ], ] # hierarchical3 /edit => { /contact => [ name=(\w+);city=(\w+);... { $r->print "Edit '$name' in '$city'"; }, name=(\w+);job=(.*);... { $r->print "Edit '$name' who does '$job'"; }, ], /basket => [ items=[(\w+)];... { $r->print "Edit items in basket"; }, delivery=(\w+);... { $r->print "Edit delivery details"; }, ], }
etc

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found