"Use of initialized value in scalar assignment"

K

kj

The following innocent-looking one-liner:

% perl -we '$ENV{ FOO } = undef'

produces the warning:

Use of uninitialized value in scalar assignment at -e line 1

Is this a bug, or is there a good reason for this?

FWIW, I've seen this behavior only with %ENV. I got the above
using v5.8.8 on Linux.

TIA!

kj
 
J

John W. Krahn

kj said:
The following innocent-looking one-liner:

% perl -we '$ENV{ FOO } = undef'

produces the warning:

Use of uninitialized value in scalar assignment at -e line 1

Is this a bug, or is there a good reason for this?

FWIW, I've seen this behavior only with %ENV. I got the above
using v5.8.8 on Linux.

What makes you think that you could set an environment variable to the
undef value? How does that make sense?

man 3 setenv


Perhaps you meant to use delete() instead:

delete $ENV{ FOO }



John
 
J

John Bokma

kj said:
The following innocent-looking one-liner:

% perl -we '$ENV{ FOO } = undef'

produces the warning:

Use of uninitialized value in scalar assignment at -e line 1

Is this a bug, or is there a good reason for this?

FWIW, I've seen this behavior only with %ENV. I got the above
using v5.8.8 on Linux.

What do you expect from setting an environment variable to undef?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top