7
71Mach1
Hello, I recently created a simple form via a .pl script.
Here it is:
#!/usr/bin/perl
# cgi-bin/ice-cream: program to answer *and generate* ice cream
# CV Form Version 2.0: Uses more while/for/foreach loops to get the
job done.
# Created: 8/15/05 RH
use strict; # enforce variable declarations and quoting
use CGI qwstandard);
print header, start_html("Carrier Validation Test Architecture"),
h1("Carrier Validation Test Architecture");
if (param()) { # the form has already been filled out
my $date = param("date");
my $Carrier = param("Carrier");
my $T1 = param("T1");
my $T2 = param("T2");
my $T3 = param("T3");
my $T4 = param("T4");
my $T5 = param("T5");
my $T6 = param("T6");
my $T7 = param("T7");
my $T8 = param("T8");
my $T9 = param("T9");
my $T10 = param("T10");
my $T11 = param("T11");
my $T12 = param("T12");
my $T13 = param("T13");
my $T14 = param("T14");
my $T15 = param("T15");
my $T16 = param("T16");
my $T17 = param("T17");
my $T18 = param("T18");
my $T19 = param("T19");
my $T20 = param("T20");
my
$TESTS=($T1,$T2,$T3,$T4,$T5,$T6,$T7,$T8,$T9,$T10,$T11,$T12,$T13,$T14,$T15,$T16,$T17,$T18,$T19,$T20);
my $NUM = 1;
my $EXPR = /a-zA-Z0-9/;
print p("$date");
print p("$Carrier");
print p("@TESTS");
my $count = 0;
foreach my $TEST (@TESTS) {
if ($TEST[$count] != 'EMPTY') {
print p( "$NUM",". ","$TEST",checkbox( -NAME=> "P"),checkbox(
-NAME=>"F"));
$NUM++;
$count++;
}}
} else {# FIRST TIME THROUGH, PRESENT A CLEAN FORM
print hr(); # draw a horizontal rule before the form
print start_form();
print p("What is the date? ", textfield("date"));
print p("Carrier: ", popup_menu("Carrier", ['A','B','C','T-MobileUK',
'D', 'E']));
print p("What is the Suite Title? ", textfield( -NAME=> 'SuiteTitle',
-SIZE => 65));
print p("Enter the test case names of the suite you would like to have
reviewed");
print p(" 1. ", textfield( -NAME=> "T1", -SIZE => 65));
print p(" 2. ", textfield( -NAME=> "T2", -SIZE => 65));
print p(" 3. ", textfield( -NAME=> "T3", -SIZE => 65));
print p(" 4. ", textfield( -NAME=> "T4", -SIZE => 65));
print p(" 5. ", textfield( -NAME=> "T5", -SIZE => 65));
print p(" 6. ", textfield( -NAME=> "T6", -SIZE => 65));
print p(" 7. ", textfield( -NAME=> "T7", -SIZE => 65));
print p(" 8. ", textfield( -NAME=> "T8", -SIZE => 65));
print p(" 9. ", textfield( -NAME=> "T9", -SIZE => 65));
print p("10. ", textfield( -NAME=> "T10", -SIZE => 65));
print p("11. ", textfield( -NAME=> "T11", -SIZE => 65));
print p("12. ", textfield( -NAME=> "T12", -SIZE => 65));
print p("13. ", textfield( -NAME=> "T13", -SIZE => 65));
print p("14. ", textfield( -NAME=> "T14", -SIZE => 65));
print p("15. ", textfield( -NAME=> "T15", -SIZE => 65));
print p("16. ", textfield( -NAME=> "T16", -SIZE => 65));
print p("17. ", textfield( -NAME=> "T17", -SIZE => 65));
print p("18. ", textfield( -NAME=> "T18", -SIZE => 65));
print p("19. ", textfield( -NAME=> "T19", -SIZE => 65));
print p("20. ", textfield( -NAME=> "T20", -SIZE => 65));
print p("Submit for verification ", popup_menu("SUBMIT", [ 1..3 ]));
print p(submit("SUBMIT"), reset("CLEAR"));
print end_form(), hr();
}
print end_html;
As you can see, I'm assigning all the textfield values to @TESTS and
then I'm trying to seperate them out and only print $NUM and $TEST
while values of the array are not empty. You can see that what I am
trying to do is to only print out while the $TEST value is not equal to
"". I've tried several if statments to try to get it and I've browsed
all of the 3 books that I have but I can't find a solution to NOT print
if the array value equals blank.
Any ideas????
Here it is:
#!/usr/bin/perl
# cgi-bin/ice-cream: program to answer *and generate* ice cream
# CV Form Version 2.0: Uses more while/for/foreach loops to get the
job done.
# Created: 8/15/05 RH
use strict; # enforce variable declarations and quoting
use CGI qwstandard);
print header, start_html("Carrier Validation Test Architecture"),
h1("Carrier Validation Test Architecture");
if (param()) { # the form has already been filled out
my $date = param("date");
my $Carrier = param("Carrier");
my $T1 = param("T1");
my $T2 = param("T2");
my $T3 = param("T3");
my $T4 = param("T4");
my $T5 = param("T5");
my $T6 = param("T6");
my $T7 = param("T7");
my $T8 = param("T8");
my $T9 = param("T9");
my $T10 = param("T10");
my $T11 = param("T11");
my $T12 = param("T12");
my $T13 = param("T13");
my $T14 = param("T14");
my $T15 = param("T15");
my $T16 = param("T16");
my $T17 = param("T17");
my $T18 = param("T18");
my $T19 = param("T19");
my $T20 = param("T20");
my
$TESTS=($T1,$T2,$T3,$T4,$T5,$T6,$T7,$T8,$T9,$T10,$T11,$T12,$T13,$T14,$T15,$T16,$T17,$T18,$T19,$T20);
my $NUM = 1;
my $EXPR = /a-zA-Z0-9/;
print p("$date");
print p("$Carrier");
print p("@TESTS");
my $count = 0;
foreach my $TEST (@TESTS) {
if ($TEST[$count] != 'EMPTY') {
print p( "$NUM",". ","$TEST",checkbox( -NAME=> "P"),checkbox(
-NAME=>"F"));
$NUM++;
$count++;
}}
} else {# FIRST TIME THROUGH, PRESENT A CLEAN FORM
print hr(); # draw a horizontal rule before the form
print start_form();
print p("What is the date? ", textfield("date"));
print p("Carrier: ", popup_menu("Carrier", ['A','B','C','T-MobileUK',
'D', 'E']));
print p("What is the Suite Title? ", textfield( -NAME=> 'SuiteTitle',
-SIZE => 65));
print p("Enter the test case names of the suite you would like to have
reviewed");
print p(" 1. ", textfield( -NAME=> "T1", -SIZE => 65));
print p(" 2. ", textfield( -NAME=> "T2", -SIZE => 65));
print p(" 3. ", textfield( -NAME=> "T3", -SIZE => 65));
print p(" 4. ", textfield( -NAME=> "T4", -SIZE => 65));
print p(" 5. ", textfield( -NAME=> "T5", -SIZE => 65));
print p(" 6. ", textfield( -NAME=> "T6", -SIZE => 65));
print p(" 7. ", textfield( -NAME=> "T7", -SIZE => 65));
print p(" 8. ", textfield( -NAME=> "T8", -SIZE => 65));
print p(" 9. ", textfield( -NAME=> "T9", -SIZE => 65));
print p("10. ", textfield( -NAME=> "T10", -SIZE => 65));
print p("11. ", textfield( -NAME=> "T11", -SIZE => 65));
print p("12. ", textfield( -NAME=> "T12", -SIZE => 65));
print p("13. ", textfield( -NAME=> "T13", -SIZE => 65));
print p("14. ", textfield( -NAME=> "T14", -SIZE => 65));
print p("15. ", textfield( -NAME=> "T15", -SIZE => 65));
print p("16. ", textfield( -NAME=> "T16", -SIZE => 65));
print p("17. ", textfield( -NAME=> "T17", -SIZE => 65));
print p("18. ", textfield( -NAME=> "T18", -SIZE => 65));
print p("19. ", textfield( -NAME=> "T19", -SIZE => 65));
print p("20. ", textfield( -NAME=> "T20", -SIZE => 65));
print p("Submit for verification ", popup_menu("SUBMIT", [ 1..3 ]));
print p(submit("SUBMIT"), reset("CLEAR"));
print end_form(), hr();
}
print end_html;
As you can see, I'm assigning all the textfield values to @TESTS and
then I'm trying to seperate them out and only print $NUM and $TEST
while values of the array are not empty. You can see that what I am
trying to do is to only print out while the $TEST value is not equal to
"". I've tried several if statments to try to get it and I've browsed
all of the 3 books that I have but I can't find a solution to NOT print
if the array value equals blank.
Any ideas????