Re: really bad use of postfix



Ken Foskey wrote:
Just like to show how NOT to use postfix. I have had a frustrating day
tackling this type of unreadable code.

exec_rqst('stga2k_vps.pl',$FileNameIn) if ($a2kqual[4] eq
"VPS");
exec_rqst('stga2kif.sh',$FileNameIn) if ($a2kqual[4] ne
"VPS");


if ($a2kqual[4] eq "VPS") {
exec_rqst('stga2k_vps.pl',$FileNameIn);
}
else {
exec_rqst('stga2kif.sh',$FileNameIn);
}

How about this?

exec_rqst(
$a2kqual[ 4 ] eq 'VPS' ? 'stga2k_vps.pl' : 'stga2kif.sh',
$FileNameIn
);



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.



Relevant Pages