in reply to Marking "checkbox" html field checked
Anyway, if you wanna stick with variable interpolation, using a dedicated hash might be better (shorter, self documenting, less error prone,...)
my %CHECKED = ( "" => "", 1 => 'checked="checked"'); print "<yadda $CHECKED{ !! $fieldValues{fieldName} } yadda>"
If you don't like the !! double negation make either sure that the values are only true or false (resp. binary) or use a tied hash to do the boolean mapping inside the FETCH.
Making %CHECKED constant or immutable might be a good idea too.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|