Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Re: same 500 server error problem shorter question

by Cirollo (Friar)
on Jun 06, 2001 at 18:45 UTC ( [id://86242]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: same 500 server error problem shorter question
in thread same 500 server error problem shorter question

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://86242]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2024-04-19 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found