"Use of initialized value in scalar assignment"

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
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
kj [ Mi, 02 Januar 2008 21:14 ] [ ID #1898391 ]

Re: "Use of initialized value in scalar assignment"

kj wrote:
>
> 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
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
someone [ Mi, 02 Januar 2008 21:27 ] [ ID #1898393 ]

Re: "Use of initialized value in scalar assignment"

kj <socyl [at] 987jk.com.invalid> wrote:

> 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?

--
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1. html
John Bokma [ Mi, 02 Januar 2008 21:28 ] [ ID #1898394 ]
Perl » comp.lang.perl.misc » "Use of initialized value in scalar assignment"

Vorheriges Thema: import trick
Nächstes Thema: FAQ 6.10 How do I use a regular expression to strip C style comments from a file?