Re: fun with hashes!

2007-11-23 Thread Steven W. Orr
On Friday, Nov 23rd 2007 at 14:53 -, quoth Jerrad Pierce: =I admit I'm better with python these days than I am with perl, but one of =the caveats that the dispatch table should be taught with is that =selecting the correct code ref is different from calling through it. = =You might want to

Re: fun with hashes!

2007-11-23 Thread Uri Guttman
AP == A Pagaltzis [EMAIL PROTECTED] writes: AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]: exists( $dispatch{$sub} ) ? $dispatch{$sub}-() : warn Key $sub does not exist in the dispatch table; AP ( $dispatch{$sub} || sub { warn no such action '$sub' } )-(); some

Re: fun with hashes!

2007-11-23 Thread Mr. Shawn H. Corey
A. Pagaltzis wrote: * Mr. Shawn H. Corey [EMAIL PROTECTED] [2007-11-24 00:50]: my $sub = ( exists $dispatch{ $key } ref( $dispatch{ $key } ) eq 'CODE' ) ? $dispatch{ $key } : $dispatch{ 'default' }; Just because you're not paranoid doesn't mean computers don't hate you :)

Re: fun with hashes!

2007-11-23 Thread Danny Brian
Tied hashes a la Regexp::Common.

Re: fun with hashes!

2007-11-23 Thread Vladi Belperchinov-Shabanski
On Fri, 23 Nov 2007 23:18:20 +0100 A. Pagaltzis [EMAIL PROTECTED] wrote: * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]: exists( $dispatch{$sub} ) ? $dispatch{$sub}-() : warn Key $sub does not exist in the dispatch table; ( $dispatch{$sub} || sub { warn no such action

Re: fun with hashes!

2007-11-23 Thread Uri Guttman
SHC == Shawn H Corey [EMAIL PROTECTED] writes: SHC Vladi Belperchinov-Shabanski wrote: On Fri, 23 Nov 2007 23:18:20 +0100 A. Pagaltzis [EMAIL PROTECTED] wrote: * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]: exists( $dispatch{$sub} ) ? $dispatch{$sub}-() : warn Key

Re: fun with hashes!

2007-11-23 Thread A. Pagaltzis
* Mr. Shawn H. Corey [EMAIL PROTECTED] [2007-11-24 00:50]: my $sub = ( exists $dispatch{ $key } ref( $dispatch{ $key } ) eq 'CODE' ) ? $dispatch{ $key } : $dispatch{ 'default' }; Just because you're not paranoid doesn't mean computers don't hate you :) So why did you skip

Re: fun with hashes!

2007-11-23 Thread Mr. Shawn H. Corey
Steven W. Orr wrote: On Friday, Nov 23rd 2007 at 14:53 -, quoth Jerrad Pierce: =I admit I'm better with python these days than I am with perl, but one of =the caveats that the dispatch table should be taught with is that =selecting the correct code ref is different from calling through it.

Re: fun with hashes!

2007-11-23 Thread Steven W. Orr
on Friday, Nov 23rd 2007 at 13:12 -, quoth Uri Guttman: = =too long has this list been quiet. but i have a fun question. i am =writing up slides for an all about hashes class. one goal i have is to =list and explain as many different uses for hashes as reasonably =possible. i have a short

Re: fun with hashes!

2007-11-23 Thread Mr. Shawn H. Corey
Uri Guttman wrote: too long has this list been quiet. but i have a fun question. i am writing up slides for an all about hashes class. one goal i have is to list and explain as many different uses for hashes as reasonably possible. i have a short list to start with but i am sure the hive mind of

Re: fun with hashes!

2007-11-23 Thread Scott Wiersdorf
On Fri, Nov 23, 2007 at 01:12:37PM -0500, Uri Guttman wrote: isa is a key valid? (not same as in a set). isa usually works on fixed sets of keys my @foos = qw( axxj djdj whwh ) ; my %is_a_foo = map { $_ = 1 } @foos I don't have

Re: fun with hashes!

2007-11-23 Thread A. Pagaltzis
* Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]: exists( $dispatch{$sub} ) ? $dispatch{$sub}-() : warn Key $sub does not exist in the dispatch table; ( $dispatch{$sub} || sub { warn no such action '$sub' } )-(); -- *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined

Re: fun with hashes!

2007-11-23 Thread Uri Guttman
SW == Scott Wiersdorf [EMAIL PROTECTED] writes: SW I don't have any additional uses for hashes to add, but I do have a SW great hash initializer I picked up from Damian when he was in town a SW few years ago (borrowing from your example): SW my @foos = qw( axxj djdj whwh ) ; SW my

Re: fun with hashes!

2007-11-23 Thread Mr. Shawn H. Corey
Uri Guttman wrote: AP == A Pagaltzis [EMAIL PROTECTED] writes: AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]: exists( $dispatch{$sub} ) ? $dispatch{$sub}-() : warn Key $sub does not exist in the dispatch table; AP ( $dispatch{$sub} || sub { warn no such action '$sub' }