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

Discussion in 'Perl Misc' started by Sunil, Oct 6, 2003.

  1. Sunil

    Sunil Guest

    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.
    Sunil, Oct 6, 2003
    #1
    1. Advertising

  2. Sunil

    Sisyphus Guest

    Sunil wrote:
    > 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

    --
    To reply by email u have to take out the u in kalinaubears.
    Sisyphus, Oct 6, 2003
    #2
    1. Advertising

  3. Sunil

    Matija Papec Guest

    On Mon, 6 Oct 2003 11:41:14 +0530, "Sunil"
    <> wrote:

    >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.
    Matija Papec, Oct 6, 2003
    #3
  4. Sunil

    Sunil Guest

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

    Thanks Again,
    Sunil.



    "Matija Papec" <> wrote in message
    news:...
    > On Mon, 6 Oct 2003 11:41:14 +0530, "Sunil"
    > <> wrote:
    >
    > >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.
    >
    >
    Sunil, Oct 6, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    3
    Views:
    958
    Tony Morris
    Feb 9, 2004
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,763
    Smokey Grindel
    Dec 2, 2006
  3. Replies:
    3
    Views:
    84
  4. Tim McDaniel

    undef($foo) versus $foo = undef()?

    Tim McDaniel, Aug 19, 2009, in forum: Perl Misc
    Replies:
    6
    Views:
    136
    Peter J. Holzer
    Aug 19, 2009
  5. Willem
    Replies:
    62
    Views:
    629
    Ilya Zakharevich
    Sep 9, 2011
Loading...

Share This Page