develooper Front page | perl.perl5.porters | Postings from February 2000

[PATCH] Document splice(@array)

Thread Next
From:
Gisle Aas
Date:
February 18, 2000 06:22
Subject:
[PATCH] Document splice(@array)
Message ID:
m3r9eabp7m.fsf@eik.g.aas.no
I recently used splice without any arguments besides the array in some
code of mine:

    for (splice(@array)) {
       ...
       push(@array, $_) if some_condition($_);
       ...
    }

I think we should document that this is legal and what it does.  The
following patch does exactly that.

Regards,
Gisle


Index: pod/perlfunc.pod
===================================================================
RCS file: /local/perl/build/CVSROOT/perl5.6tobe/pod/perlfunc.pod,v
retrieving revision 1.1.1.2
diff -u -p -u -r1.1.1.2 perlfunc.pod
--- pod/perlfunc.pod	2000/02/09 22:25:31	1.1.1.2
+++ pod/perlfunc.pod	2000/02/18 13:32:54
@@ -4160,6 +4160,8 @@ well-defined.
 
 =item splice ARRAY,OFFSET
 
+=item splice ARRAY
+
 Removes the elements designated by OFFSET and LENGTH from an array, and
 replaces them with the elements of LIST, if any.  In list context,
 returns the elements removed from the array.  In scalar context,
@@ -4168,6 +4170,8 @@ removed.  The array grows or shrinks as 
 If OFFSET is negative then it starts that far from the end of the array.
 If LENGTH is omitted, removes everything from OFFSET onward.
 If LENGTH is negative, leave that many elements off the end of the array.
+If both OFFSET and LENGTH are omitted, remove everything.
+
 The following equivalences hold (assuming C<$[ == 0>):
 
     push(@a,$x,$y)	splice(@a,@a,0,$x,$y)



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About