[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] unknown error question



On Thu, Jun 10, 1999 at 08:21:02AM -0500, Robert Pollard wrote:
> You know I tried to figure out why it would complain about the variable
> being used only once when MacPerl doesn't require you to declare
> variables there is a possibility that you would only use the variable
> once.
> 
> BTW this is all of the code.  I was having the warning in some other code
> and decided to paste it into a new window and try it.  So,  I guess what
> I am saying is, this doesn't make sense.  As with computers, I have found
> out, not making sense is normal.  I am use to retyping errors and other
> variable related errors, but telling you that you have only used a
> variable once does not make sense.  I guess someone out there knew
> exactly what they were doing when they put it in there.

When you ask Perl to give you warnings, Perl gives you warnings.  Note,
once again, that this particular message is a warning, and not an error,
which is why (A) it is and optional and (B) it does not halt execution of
your program.

It is very rare that a program would need to use a variable exactly once; a
variable stores a value so you can refer to it again later.  If you're not
referring to the value again later, what is the variable for?  Thus, this
warning makes a great deal of sense, and in cases where it does not apply
you can easily avoid the warning with use vars.


> One of the respondents mentioned the keyword "my."  Am I to understand
> this is a way of declaring local variables?  I have looked for it in
> documentation but haven't run across it yet.  I use Chris & Vicki's book
> and the on-line documentation.

my() is documented in perlfunc, among other places.


Ronald

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org