Perl syntax

John Wildberger wildberger-iRg7kjdsKiH3fQ9qLvQP4Q at public.gmane.org
Mon May 30 15:25:18 UTC 2005


On Monday 30 May 2005 10:18 am, Anthony wrote:
> It is very important that you understand exactly what
> it is you are doing to fix the errors. Someone said
> just put
>
> my $var="data";
>
>  True it does stop the error messages but unless you
> understand the correct scoping in the variables, your
> program will have a lot worse logic problems down the
> road.
>
> You have to ensure your variables are scoped properly.
> For example, when you:
> use strict;
>
> You must ensure to declare whether your variables are
> dynmaically or lexically scoped.
> Therefore you cannot declare a variable like this:
>
> $var="data";
>
> You have to tell the Perl interpreter in which blocks
> the variables are valid.
Thanks,
I think I know the scoping issue. What confused me was the wording of the 
error message:
 Global symbol "%count" requires explicit package name.
It would have been more meaningful if the error message would have said 
something to the effect that the variables were not declared before they were 
used.
John
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list