Results 1 to 2 of 2
Hello
Here is the chunk of code that doesn't want to work with me:
Code:
#!/usr/bin/perl -wT
use strict;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use CGI qw/:standard/;
my $media_type = param('media_type');
...
- 07-20-2008 #1
[SOLVED] problems with subroutines
Hello
Here is the chunk of code that doesn't want to work with me:
Code:#!/usr/bin/perl -wT use strict; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use CGI qw/:standard/; my $media_type = param('media_type'); print header; print start_html('New Order'),"New Order"; print start_form(-method=>'get'); if ($media_type == "film"){ &film_form(); } elsif ($media_type == "tapes"){ &tapes_form(); } elsif ($media_type == "sildes/photo"){ &slides_form(); } elsif ($media_type == "audio-tapes"){ &tapes_form(); } else { &media_type_form(); } print end_form; print end_html; #------------------------------------------------------- #------------------------------------------------------- # allow to select media type sub media_type_form { print "Media Type: ", scrolling_list('media_type', ['','film','tapes','slides/photo','audio-tapes'], -size=>1), br, submit(-name=>'select',-value=>'select'); } #------------------------------------------------------- #------------------------------------------------------- # displays form for FILM media sub film_form { print "FILM FORM"; } #------------------------------------------------------- #------------------------------------------------------- # displays form for TAPES media sub tapes_form { print "TAPES FORM"; } #------------------------------------------------------ #------------------------------------------------------- # dispplays form for SLIDES/PHOTOS sub slides_form { print "TAPES FORM"; } #------------------------------------------------------- #------------------------------------------------------- # displays form for AUDIO tapes sub audio_form { print "AIDIO TAPES FORM"; } #------------------------------------------------------- __END__
When I run it I get the following;
When it runs for the first time its suppose to give a select menu to choose media type, but instead it thinks that FILM media was selected.Code:New Order FILM FORM
Can any one help me?
Thank you.
- 07-20-2008 #2
Well I solved this by replacing '==' with 'eq'.
Code:if ($media_type == "film"){ &film_form(); } elsif ($media_type == "tapes"){ &tapes_form(); } elsif ($media_type == "sildes/photo"){ &slides_form(); } elsif ($media_type == "audio-tapes"){ &tapes_form(); } else { &media_type_form(); }


