why do I see - Use of uninitialized value in undef operator ...

S

Sunil

All,
I have the following code which throws "Use of uninitialized value in
undef operator at ....." when warnings is turned on. Can anyone please
explain this behaviour.

undef $ENV{'NLS_LANG'} if(defined $ENV{'NLS_LANG'});


Thanks,
Sunil.
 
S

Sisyphus

Sunil said:
All,
I have the following code which throws "Use of uninitialized value in
undef operator at ....." when warnings is turned on. Can anyone please
explain this behaviour.

undef $ENV{'NLS_LANG'} if(defined $ENV{'NLS_LANG'});

Can't explain it but the docs warn about it and tell you what to do
about it.

See:
perldoc -f undef
perldoc -f delete

Cheers,
Rob
 
M

Matija Papec

All,
I have the following code which throws "Use of uninitialized value in
undef operator at ....." when warnings is turned on. Can anyone please
explain this behaviour.

undef $ENV{'NLS_LANG'} if(defined $ENV{'NLS_LANG'});

Don't use undef function(perldoc -f undef); if you want to delete key
then,
delete $ENV{'NLS_LANG'};
and
$ENV{'NLS_LANG'} = undef;
in case you want to set /value/ of $ENV{'NLS_LANG'} to undef.
 
S

Sunil

Thanks a lot to all who replied.
delete $ENV{'NLS_LANG'};
has solved my problem.

Thanks Again,
Sunil.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top