Re: Sub routine location
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 28 Dec 2005 07:28:54 -0800
sunckell wrote:
> Thanks for the input...
Who are you thanking? For what input? Please quote some context in
your replies. Please see the Posting Guidelines that are posted here
twice a week for more good advice.
> As for "MAIN" if I make a syntax error in my subroutine somewhere, i
> have seen errors that resemble..
>
> error at some line number in &subroutine::main.
>
> Or something similar. I am assuming main is section of script that
> does the calling to subroutines etc. I guess I am wrong?
Difficult to know without a more precise example. That particular form
of an error message isn't jumping out at me as immediately familiar.
Perhaps you could contrive an example which generates this sort of
error message, and then copy and paste it directly?
> I thought I would ask this becuase I have noticed certian warnings (
> I'll have to test this since I am remebering what I have seen) when
> subroutines are at the bottom of the script and I call them just by
> subroutine_name($var1,$var2) and not like
> &subroutine_name($var1,$var2).
My guess would be that this relates to one of the two "exceptions" I
noted in my first reply to your initial question - When your
subroutines are declared after being called, prototypes are not
enforced, and you get a warning telling you about it. When you call a
subroutine using the & in front of the name, that tells perl to disable
prototype checking. Perl assumes you are specifically asking for that
feature, and so doesn't bother warning you that it can't check the
prototypes in the first place.
A good rule of thumb is to never use & unless you know exactly what
reason you have to use it. 99% of the time, you don't have any reason
to.
Paul Lalli
.
- Follow-Ups:
- Re: Sub routine location
- From: Gunnar Hjalmarsson
- Re: Sub routine location
- References:
- Sub routine location
- From: sunckell
- Re: Sub routine location
- From: Bernard El-Hagin
- Re: Sub routine location
- From: sunckell
- Sub routine location
- Prev by Date: Re: grep: \" and " both Give Errors
- Next by Date: 'file changed'-event
- Previous by thread: Re: Sub routine location
- Next by thread: Re: Sub routine location
- Index(es):
Relevant Pages
|