First if statement.
$length = length($firstname); if (!$length) { print "Not a valid First Name, try again.\n"; next; ---> { Greg Smith > -----Original Message----- > From: t [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 14, 2003 4:05 PM > To: [EMAIL PROTECTED] > Subject: Perl problem:( > > > Hello all:) > > You have been greaet helps to me in the past, and im hoping you > can help now:) A friend of mine is > in a class learning perl and her script keeps getting an error > that there is a bracket missing on > line 190. When i looked at it, all i could see was the nested > statement problem i had at one time. > Do you think that is the problem? and if so, what would be the > best way to fix it? I want her to > be able to learn it, not to have it done for her, but i want to > give her the best advice possible: > > Script::: > > #!/usr/bin/perl > # > # lab3.pl > # > > my @scorearray; > > sub getinformation() > { > > local $score = 0; > local $total = 0; > local $ctr = 0; > local $rpt_ctr = 0; > open (OUTFILE, ">>info.txt") > || die "cannot open info.txt $!"; > > local $var = "bad"; > while ($var eq "bad") > { > print "enter student's first name: "; > $firstname = <STDIN>; > chop ($firstname); > $length = length($firstname); > if (!$length) > { > print "Not a valid First Name, try again.\n"; > next; > { > if($length > 20) > { > print "Not a valid First Name, try again. \n"; > next; > } > if($length) > { > $var = "good"; > print (OUTFILE "$firstname|"); > } > } > > local $var1 = "bad"; > while ($var1 eq "bad") > { > > print "enter student's last name: "; > $lastname = <STDIN>; > chop ($lastname); > > if (!$length1) > { > print "Not a valid last name, try again. \n"; > next; > } > if($length1 > 20) > { > print "Not a valid last name, try again. \n"; > next; > } > if($length1) > { > $var1 = "good"; > print(OUTFILE "$lastname|"); > } > } > > local $var2 = "bad"; > while($var2 = "bad") > > { > print "enter student's SSN:"; > $ssn = <STDIN>; > chop($ssn); > > $length2=length($ssn); > if(!$length2) > { > print "Not a valid Social Security Number, > try again.\n"; > next; > } > $ssn =~ s/[^\d]//g; > if($ssn !~ m/^\d{9}$/) > { > print "Not a valid Social Security Number, > try again.\n"; > next; > } > if($ssn =~ m/^\d{9}$/) > { > $var2 = "good"; > print(OUTFILE "$ssn"); > } > } > > > local $ctr1 = 1; > while ($ctr < 4) > { > > print "enter a test score $ctr1: "; > $score = <STDIN>; > chop ($score); > > if ($score eq "q") > { > last; > } > > local $error = "true"; > testscore($score); > > if ($error eq "false") > { > next; > } > else > { > $total += $score; > $ctr++; > $ctr1++; > $scorearray[$ctr]=$score; > } > > }; > > while($rpt_ctr <= $ctr) > { > print (OUTFILE "$scorearray[$rpt_ctr]"); > > if($rpt_ctr < 3) > { > print(OUTFILE "|"); > } > > $rpt_ctr++; > } > > print (OUTFILE "\n"); > getscore(); > }; > > sub getscore() > { > local $display = 4 - $ctr; > local $avg = $total / 4; > print "Score total is $total \n"; > print "number of scores entered is $ctr \n"; > print "Score Average is $avg \n"; > print "$firstname is missing $display tests\n"; > warnings(); > }; > > sub testscore() > { > if ($score > 100) > { > print "invalid score, please make sure the score is > less than or equal to 100\n"; > $error = "false"; > } > if ($score < 0) > { > print "invalid score, please make sure the score is > greater than or equal to 0\n"; > $error = "false"; > } > }; > > sub warnings() > { > if ($avg <= 60) > { > print "Grim Warning, $firstname !"; > } > elsif ($avg <= 70) > { > print "Uh-oh! You maybe in trouble, $firstname !"; > } > elsif ($avg <= 80) > { > print "Good going $firstname \n You have a > satisfactory grade \n"; > } > elsif ($avg <= 90) > { > print "Way to go $firstname \n You have a > satisfactory grade \n"; > } > else > { > print "Way to go $firstname \n You are AWESOME!\n"; > } > }; > > getinformation(); > > > Thanks in Advance:):):):) > > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Shopping - Send Flowers for Valentine's Day > http://shopping.yahoo.com > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]