in reply to A Case with 5 Var's
A neat trick that may, or may not, help (depending on what you are trying to achieve) is to generate a bit vector:
use strict; use warnings; my $name = ''; my $vorname = 'full'; my $plz = 1; my $tel = 0; my $tel49 = undef; my $vector = (!$name) || 2; $vector |= (!$vorname) || 4; $vector |= (!$plz) || 8; $vector |= (!$tel) || 16; $vector |= (!$tel49) || 32; printf "%06b\n", $vector;
which sets a bit in $vector for each "true" variable. As a bonus it sets the least significant bit if any of the variables is false. Note BTW that there is a big difference between defined and "true". The sample prints:
001101
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A Case with 5 Var's
by ultibuzz (Monk) on Jan 25, 2007 at 12:45 UTC | |
by GrandFather (Saint) on Jan 25, 2007 at 21:56 UTC |