Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: undef'ing @arrays caveat

by Maclir (Curate)
on Apr 20, 2002 at 01:21 UTC ( #160718=note: print w/replies, xml ) Need Help??

in reply to undef'ing @arrays caveat

What you need to determine first is "what does it mean for an array to be undefined?" If we takes as our definition that an array with no elements is undefined, then the standard (and self evident) way is to assign an empty array to it: @array = ();.

Replies are listed 'Best First'.
Re: Re: undef'ing @arrays caveat
by dmmiller2k (Chaplain) on Apr 20, 2002 at 22:50 UTC

    True, and in fact if you undef @array the effect is identical. See my node, above.

      True, and in fact if you undef @array the effect is identical.

      Try using Devel::Peek. undef @array sets MAX to -1, @array = () does not. Or use Benchmark and find out that undef @array is about twice as fast. The effect is the same, but internally, there's something entirely different going on.

      - Yes, I reinvent wheels.
      - Spam: Visit eurotraQ.

        Granted. But besides the speed issue, the result is effectively the same.

        In the case of undef @array, @array does not actually get undefined (i.e., it still exists), just emptied, however more efficiently than with @array = ().

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://160718]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2023-09-22 05:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found