in reply to defined array question

perldoc -f defined tells us:

Use of "defined" on aggregates (hashes and arrays) is deprecated. It used to report whether memory for that aggregate has ever been allocated. This behavior may disappear in future versions of Perl.

So that's a bad thing and you shouldn't do that.

But you're not using defined on an array, you're using defined on an array slice. perldoc -f defined is silent on what this does, so the behaviour is undefined. Which means that it's quite possible for it to change between versions of Perl or different architectures.

As others have pointed out, it's difficult to really know what you are trying to do there. Once you've worked it out, we can help you to reimplement it in "real" Perl.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: defined array question
by toadi (Chaplain) on Aug 30, 2002 at 13:45 UTC
    If you read my root post you'll see it was written by a other programmer and also I'm trying to figure out what it does or what he wanted to accomplish! Off course the easiest way is to ask him, but it was a consultant who already left the company an even left the country :)

    I'm just trying to fix some code and add some functionality in 'his' code...



    --
    My opinions may have changed,
    but not the fact that I am right

Re: Re: defined array question
by cfreak (Chaplain) on Aug 30, 2002 at 14:28 UTC
    But you're not using defined on an array, you're using defined on an array slice. perldoc -f defined is silent on what this does

    Considering that an array slice still returns an array I'd say the behaviour would be the same and should be considered depreciated. The only exception I see is if the slice is just one element, then you are performing defined on a scalar which I assume is still okay. :)

    Chris

    Lobster Aliens Are attacking the world!
      Considering that an array slice still returns an array I'd say the behaviour would be the same

      Nope. An array slice returns a list, not an array.

      depreciated

      That's "deprecated". "Depreciated" means something completely different.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg