t wrote:
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:

Time to start reading ;-)....

perldoc -f chomp
perldoc -f chop
perldoc -f my
perldoc -f our
perldoc -f local

2 rules first off...
Don't ever use 'chop'...at least not until you know why you should never use chop, then you can....
Don't ever use 'local'...at least not until you know why you should never use local, then you can ;-)....

http://perl.plover.com/FAQs/Namespaces.html

Where is the:

use strict;
use warnings;

???

perldoc perlstyle (wouldn't hurt to have a glance at)

1. Don't need semi-colons after sub routine definitions or other blocks.
2. In general it is considered ok to put the 'main' of a Perl program into the actual 'main' rather than in a subroutine that is the only thing called.
3. In general the main of Perl goes before the sub definitions.
4. Don't want (need) empty parenthesis in a sub definition, I am not sure but this might actually force the sub to not allow args?
5. "warnings" is a VERY bad name for a subroutine, don't use it.
6. Multiple if statements involving the same parameter(s) can be chained using 'elsif'.
7. Very seldom should you use the same exact error/warning message twice, this will make debugging a nightmare, tell the user what they screwed up, yell it at them if it helps ;-)...
8. Return something from subroutines, test that return code.
9. Don't get frustrated, don't quit....

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;
		{
Right here is your bad brace.

		if($length > 20)

There is much much worse code in production environments, so don't get discouraged at the amount I picked on, tough love....

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to