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. Advertisements

  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. Advertisements

  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. Advertisements

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. G Kannan
    Replies:
    1
    Views:
    1,571
    Eric J. Roode
    Oct 11, 2003
  2. Sukhbir Dhillon
    Replies:
    1
    Views:
    6,527
    Joe Smith
    Apr 5, 2004
  3. smartins68
    Replies:
    1
    Views:
    6,286
    Joe Smith
    Jun 9, 2004
  4. Liang
    Replies:
    2
    Views:
    926
    Liang
    Aug 11, 2004
  5. Flip
    Replies:
    3
    Views:
    1,213
    Tony Morris
    Feb 9, 2004
  6. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,384
    Mark Rae
    Dec 21, 2006
  7. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,853
    Smokey Grindel
    Dec 2, 2006
  8. Tim McDaniel

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

    Tim McDaniel, Aug 19, 2009, in forum: Perl Misc
    Replies:
    6
    Views:
    374
    Peter J. Holzer
    Aug 19, 2009
Loading...