Re: fun with hashes!

2007-11-24 Thread David Landgren
Uri Guttman writes: 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'

Re: fun with hashes!

2007-11-24 Thread Bernie Cosell
On 23 Nov 2007 at 23:54, Uri Guttman wrote: 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(

Re: fun with hashes!

2007-11-24 Thread A. Pagaltzis
* David Landgren [EMAIL PROTECTED] [2007-11-24 10:45]: Uri Guttman writes: 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

Re: fun with hashes!

2007-11-24 Thread Vladi Belperchinov-Shabanski
On Sat, 24 Nov 2007 10:43:58 +0100 David Landgren [EMAIL PROTECTED] wrote: Uri Guttman writes: 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

Re: fun with hashes!

2007-11-24 Thread Uri Guttman
DL == David Landgren [EMAIL PROTECTED] writes: DL Uri Guttman writes: 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 (

Re: fun with hashes!

2007-11-24 Thread David Landgren
Uri Guttman writes: DL Why stop there? Assuming $key never evaluates to 0: DLmy $sub = $dispatch{ $key || 'default' }; and what if $key is true but not found?? that is a different problem. your code doesn't handle that, it only handles a false or missing key DL If it does, wait

Re: fun with hashes!

2007-11-24 Thread Uri Guttman
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' }-();

Re: fun with hashes!

2007-11-24 Thread Uri Guttman
SF == Steve Fink [EMAIL PROTECTED] writes: SF I don't think this has been mentioned, although it's really just a SF combination of two existing ones: I often have a table of sets. SF for my $user (@filenames) { SF open(my $fh, , $user) { SF while($fh) { SF

Re: fun with hashes!

2007-11-24 Thread Keith Ivey
How about using a hash to keep track of which things you've already handled? my %seen; for my $value (@values) { next if $seen{$value}++; # Do processing with $value here. } -- Keith C. Ivey [EMAIL PROTECTED] Washington, DC

Re: fun with hashes!

2007-11-24 Thread Jerrad Pierce
How about using a hash to keep track of which things you've already handled? That's just the afore-mentioned count -- Free map of local environmental resources: http://CambridgeMA.GreenMap.org -- MOTD on Pungenday, the 36th of The Aftermath, in the YOLD 3173: Wibble.