>>>>> "DL" == David Landgren <[EMAIL PROTECTED]> writes:

  DL> Although there really is little point stuffing the coderef into a
  DL> scalar, it's not like there's anything you can do to it. It's clearer to
  DL> not draw attention to it and just run the damned thing:
  DL> $dispatch{ $key || 'default' }->();
  >> there are places where you want to delay the call. you may need to pass
  >> the code ref around or call it multiple times or with different args. i
  >> have found that getting the sub is better as a separate step from
  >> calling it.

  DL> I see what you and Aristotle are saying. In my own code I arrange things
  DL> so that you're never actually feeding random strings into the dispatch
  DL> table, I make sure the values are restricted to a finite domain
  DL> beforehand, so I can't say I've been bitten by that.

and how do you do that restricting? sounds like a hash is needed there
too! :) and with outside input as in web you need to do this checking in
the server. if you know the data is clean then you can default on a
missing key but otherwise you need to check the key against the dispatch
table.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to