in reply to Re: Default Hash Key
in thread Default Hash Key
I still can't quite get my head around the way that the logical or works. I would think that it would only return 1 or 0, but evidently here it's returning the whole string back again.use strict; use warnings; my %description = ( a => 'a vowel', b => 'a consonant', default => 'not in the alphabet' ); for my $char (qw/a b c/) { my $d = $description{$char} || $description{default}; print("$char is $d\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Default Hash Key
by mrons (Beadle) on May 02, 2008 at 05:21 UTC | |
by EvanCarroll (Chaplain) on May 02, 2008 at 14:51 UTC | |
by matze (Friar) on May 03, 2008 at 12:58 UTC | |
by Anonymous Monk on May 04, 2008 at 17:10 UTC | |
|
Re^3: Default Hash Key
by roboticus (Chancellor) on May 02, 2008 at 10:42 UTC |