in reply to Hash versus chain of elsifs
More importantly, though, the hash approach is much more readable than an endless list of elsifs, and it also opens up the possibility of storing your list of items to match against in a config file or a database (since a hash's contents are just data, not code) which will make for easier long-term maintenance.
BTW, the syntax you probably want for checking whether a hash key exists is exists($hash{$string}), not defined (which will return false if the key is there but has no value).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Hash versus chain of elsifs
by mldvx4 (Friar) on Nov 22, 2021 at 09:34 UTC | |
by Fletch (Bishop) on Nov 22, 2021 at 10:15 UTC | |
by eyepopslikeamosquito (Archbishop) on Nov 22, 2021 at 09:50 UTC | |
by mldvx4 (Friar) on Nov 22, 2021 at 10:24 UTC | |
by eyepopslikeamosquito (Archbishop) on Nov 22, 2021 at 11:22 UTC | |
by eyepopslikeamosquito (Archbishop) on Nov 23, 2021 at 11:34 UTC | |
by kcott (Archbishop) on Nov 22, 2021 at 11:45 UTC | |
by eyepopslikeamosquito (Archbishop) on Nov 22, 2021 at 10:39 UTC | |
by NERDVANA (Priest) on Nov 22, 2021 at 11:04 UTC | |
| |
by choroba (Cardinal) on Nov 22, 2021 at 12:33 UTC |