Re: [vox-tech] perl redux - references
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] perl redux - references
On 08 Apr 2001 02:11 PM or thereabouts, Peter Jay Salzman wrote:
> On Sun 08 Apr 01, 1:07 PM, Henry House said:
> > On Sun, Apr 08, 2001 at 09:40:48AM -0700, Peter Jay Salzman wrote:
> > > the only error message is that this code produces is that "$James" might to a
> > > typo because it appears only once in the code. fair enough. so i uncomment
> > > line 3. NOW the error message is that $James is uninitialized.
This first warning is easy enough to explain... the 'typo' errors you are
seeing with the '-w' flag are compile time warnings. Since the symbolic
reference you are attempting to create doesn't exist until runtime, it
makes sense that it would warn you.
The warning also makes sense in the grand scheme of things, since the symbolic
reference '$James' is only assigned a value if you read a file with the
proper entries... read a file without 'James = foo', and the program is
meaningless.
> > > i don't completely grok scoping in perl, but this seems ridiculous.
> > > why would perl complain that the variable is uninitialized?
Because when you define the variable with 'my', you have referenced it
twice... once to create it, and once to read it. Thus no 'typo' errors.
But since in the 'my' statement, you left it uninitalized, you're printing
a NULL at the end of the code. (again, a compile time error, since the
warning pragmas can know nothing of run time)
> > Since I already suggested a hash, I assume you are writing this sort of code
> > to learn perl better.
>
> absolutely. perl is a language that pays you back in full for the time you
> spend in learning it.
Indubitably. ;-)
--Matthew
infinite@sigkill.com
--
"The best way to make a fire with two sticks is to make sure
one of them is a match."
-- Will Rogers
|