[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] case and elsif



I feel ashamed, but I didn't find yet a good way to do a case 
structure in Perl instead of this horrible kludge with elsif. But for 
this script to work it really have to check every condition in this 
order. Anyone want to enlighten my stupidity? Its a multiparts form.

I had a look at the Camel book (p. 104), but really, I feel lost to 
adapt the SWITCH statement to what I want to do here. And there is an 
example in the Ram book (p. 697), but maybe I'm too tired, but I 
don't see how I can put this in a hash. Maybe there a FAQ somewhere 
that I didn't look.

This snippet is working well, but I'd like to have a cleaner way to 
do the same thing.

Cheers

-Emmanuel


if ( param() == 0 ) {
	pageMotDePasse();
} elsif ( param('ok') eq $motDePasse  ) {
	pageDirection();
} elsif ( param('decide') eq "1" ) {
	pageChoix();
} elsif ( param('decide') eq "0" ) {
	pageLettre();
} elsif ( param('boutonEnrElimine') eq "Confirmer" ) {
	pageElimineAdresse();
} elsif ( param('boutonEnreg') eq "Confirmer" ){
	pageConfirmation();
} elsif ( param('texteLettre') ne "" ) {
	pageLettreConfirmation();
} elsif ( param('boutonEnvoieLettre') eq "Poster maintenant" ) {
	pageEnvoieLettre();
} elsif ( param('boutonContinuer') eq "Continuer" ) {
	pageDirection();
} elsif ( param('texteLettre')  eq "" ) {
	print header;
	print start_html;
	print h3('Erreur : Pas de texte.');
	print end_html;
} else {
	print header;
	print start_html;
	print h3('Accès interdit');
	print end_html;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Emmanuel M. Décarie - <emm@cam.org>
---> The Frontier Newbie Toolbox:
<http://www.cam.org/~emm/frontierNewbieToolbox.html>

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org