Nik has asked for the wisdom of the Perl Monks concerning the following question:
to a better maintenable one since something got me these days to perfect all my cgi scripts :-)if( !$name ) { print font( {-size=>4, -color=>'Lime'}, 'Ξέχασες + να μας πείς ποιός είσαι!<p>' ); $i=1; } if( !$pray ) { print font( {-size=>4, -color=>'Lime'}, 'Δεν σχο +λίασες την ευχή!<p>' ); $i=1; } if( !$remark ) { print font( {-size=>4, -color=>'Lime'}, 'Δεν θα +μας πείς για την εμπειρία σου?<p>' ); $i=1; } if( !$email ) { print font( {-size=>4, -color=>'Lime'}, 'Συμπλήρω +σε το email σου!<p>' ); $i=1; } exit 0 if ($i!=0);
my %error_msgs = ( name => "Ξέχασες να μας πείς ποιός είσαι!", pray => "Δεν σχολίασες την ευχή!", remark => "Δεν θα μας πείς για την εμπειρία σου?'", email => "Συμπλήρωσε το email σου!" ); my $error_found; for ( keys %error_msgs) ) { unless ( $error_msgs){$_} ) { print div( {class=>'tip'}, $%error_msgs{$_} ); $error_found++; } } exit 0 if $error_found;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Better rewrite of multiple ifs
by Dietz (Curate) on May 01, 2005 at 08:48 UTC | |
by Nik (Initiate) on May 01, 2005 at 09:20 UTC | |
|
Re: Better rewrite of multiple ifs
by eibwen (Friar) on May 01, 2005 at 08:45 UTC | |
|
Re: Better rewrite of multiple ifs
by Courage (Parson) on May 01, 2005 at 10:44 UTC | |
|
Re: Better rewrite of multiple ifs
by tlm (Prior) on May 01, 2005 at 13:14 UTC | |
| |
|
Re: Better rewrite of multiple ifs
by bradcathey (Prior) on May 01, 2005 at 11:59 UTC |