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.sub getgold { my $start= index $GoldLine, ":" + 2; return substr $start, length $line; #changed 'result' to 'return' } getgold;
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.
In reply to Re: Re: Re: same 500 server error problem shorter question
by Cirollo
in thread same 500 server error problem shorter question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |