The sad thing is that I do not know. I wrote the code using examples of different code and twisted them to my own ends.
If you can explain what they do and why one would create a sever error it would be greatly apreciated. | [reply] |
I'm not sure exactly what you want to do here, but as it stands, this part of your code doesn't do anything.
sub getgold {
my $start= index $GoldLine, ":" + 2;
return substr $start, length $line; #changed 'result' to 'return'
}
getgold;
return ends the subroutine and passes back it's arguments. So, for this to do something, you will want to get the result of the subroutine by saying $result = getgold; or some such.
So now, $result will contain a string from 2 characters after the ':' in $GoldLine to the end.
Its good programming practice to use parentheses on funtions to make it clear what you're doing. So, you should say substr($start, length $line) instead of substr $start, length $line to be more explicit.
Update:
Oops, that probably isn't doing what you want. The first argument to substr is the string that you're operating on. So, assuming you want to find a substring of $GoldLine, you would really want to say substr($GoldLine, $start, length $line). Also, if you omit that 3rd parameter, substr returns everything until the end of the string. So, you can just say substr($GoldLine, $start).
Also, if you want to see errors in your web browser instead of the dreaded "500 Server Error", add the line
use CGI::Carp qw/fatalsToBrowser/;
at the top of your script. Note that this only prints runtime errors; compiliation errors will give a rather unhelpful 'compilation failed' message.
| [reply] [d/l] [select] |