On Tue, May 29, 2001 at 03:17:41PM -0400, Jeff Pinyan ([EMAIL PROTECTED]) spew-ed forth:
> On May 29, Walt Mankowski said:
> 
> >On Tue, May 29, 2001 at 11:59:18AM -0700, Randal L. Schwartz wrote:
> >> >>>>> "Brett" == Brett W McCoy <[EMAIL PROTECTED]> writes:
> >> 
> >> >> Uh, careful.  This got added to 5.6.1 to support pseudo-hashes and is
> >> >> probably coming back out when pseudo-hashes get removed in 5.10.
> >> >> ("Death to pseudo-hashes!")
> >> 
> >> Brett> Argh.  I didn't realize that.  Is this specifically delete on array
> >> Brett> elements?
> >> 
> >> Yes.
> >
> >Is there any difference in 5.6.1 between
> >
> >     delete $array[$index];
> >
> >and
> >
> >     $array[$index] = undef;
> 
> Yes, when $index == $#array.
> 
>   @foo = ('a' .. 'z');
>   delete $foo[3];
>   print scalar @foo;  # 26
>   delete $foo[25];
>   print scalar @foo;  # 25

Also with exists()..

@array = qw(1 2 3 4 5);

delete $array[2];
print exists $array[2] ? "exists" : "doesn't exist\n";
$array[3] = undef;
print exists $array[3] ? "exists" : "doesn't exist\n";

Cheers,
Kevin

BTW.. I think this was introduced in 5.6.0, not 5.6.1. At least according to my
version of 5.6.0, and perldelta:

=head2 exists() and delete() are supported on array elements

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"If you understand what you're doing, you're not learning anything."
                -- Abraham Lincoln

Reply via email to