l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2001 Dec 30 17:04

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
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

> > > 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.  ;-) 


  "The best way to make a fire with two sticks is to make sure
   one of them is a match."
     -- Will Rogers

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.