Unusual warning - what's it trying tell me?

Discussion in 'Perl Misc' started by Derek Fountain, Aug 22, 2005.

  1. I've just inherited a rather horrible bit of code which I'm making run
    with use strict. (Yes, it's that bad.) It contains this:

    if ( ( $e > ( $rt + $ett ) )
    && ( $rt ne "" )
    && ( ${kill} == $TRUE ) )
    {

    where $kill is a local (my) variable. This produces this:

    "Ambiguous use of ${kill} resolved to $kill at ..."

    If I remove the {} from around the kill (which are unnecessary anyway)
    then the problem goes away. I've never seen that and it puzzles me.
    What's it trying to tell me? The function contains a varible called
    $killed is that makes a difference...
    Derek Fountain, Aug 22, 2005
    #1
    1. Advertising

  2. >>>>> "DF" == Derek Fountain <> writes:

    DF> && ( ${kill} == $TRUE ) )

    DF> where $kill is a local (my) variable. This produces this:

    DF> "Ambiguous use of ${kill} resolved to $kill at ..."

    DF> If I remove the {} from around the kill (which are unnecessary
    DF> anyway) then the problem goes away. I've never seen that and
    DF> it puzzles me. What's it trying to tell me?

    There's a builtin function called kill; perldoc -f kill.

    ${kill} can legitimately be interpreted as either $kill or ${kill()};
    Perl is warning you that it's interpreting it as $kill so that if you
    really meant ${kill()} you can rewrite that line.

    Removing the {} in that case is probably the wise thing to do.

    Charlton



    --
    cwilbur at chromatico dot net
    cwilbur at mac dot com
    Charlton Wilbur, Aug 22, 2005
    #2
    1. Advertising

  3. > There's a builtin function called kill; perldoc -f kill.

    So there is. I forgot about that. :eek:} Make perfect sense now...

    Thanks.
    Derek Fountain, Aug 22, 2005
    #3
    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. Pete Becker
    Replies:
    0
    Views:
    1,373
    Pete Becker
    Feb 10, 2005
  2. yogesh
    Replies:
    1
    Views:
    366
    Victor Bazarov
    Mar 14, 2007
  3. Arash Partow

    Unusual warning

    Arash Partow, Jun 1, 2007, in forum: C Programming
    Replies:
    2
    Views:
    248
    Eric Sosman
    Jun 1, 2007
  4. Jim
    Replies:
    7
    Views:
    297
    christian.bau
    Mar 22, 2008
  5. Mike A
    Replies:
    17
    Views:
    261
    Dr John Stockton
    Nov 19, 2003
Loading...

Share This Page