diff options
author | Robin Barker <RMBarker@cpan.org> | 2000-12-22 12:17:38 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-12-22 15:29:40 +0000 |
commit | 551e1d922a333f90a45a26904eb4d9882f7bd5d4 (patch) | |
tree | 165f10dcbb565db453a9cfef7096b16826754211 /pod/perlfaq4.pod | |
parent | a61357a9a84c55ce0c74b8d2bbfb23900cb5bd17 (diff) | |
download | perl-551e1d922a333f90a45a26904eb4d9882f7bd5d4.tar.gz |
; was Re: Perlbug 20000322.006 status +update
Message-Id: <200012221217.MAA21332@tempest.npl.co.uk>
p4raw-id: //depot/perl@8228
Diffstat (limited to 'pod/perlfaq4.pod')
-rw-r--r-- | pod/perlfaq4.pod | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index 23bc6665b7..1198f18a4f 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -948,7 +948,9 @@ ordered and whether you wish to preserve the ordering. =over 4 -=item a) If @in is sorted, and you want @out to be sorted: +=item a) + +If @in is sorted, and you want @out to be sorted: (this assumes all true values in the array) $prev = 'nonesuch'; @@ -959,22 +961,30 @@ uniq(1)'s behavior of removing only adjacent duplicates. The ", 1" guarantees that the expression is true (so that grep picks it up) even if the $_ is 0, "", or undef. -=item b) If you don't know whether @in is sorted: +=item b) + +If you don't know whether @in is sorted: undef %saw; @out = grep(!$saw{$_}++, @in); -=item c) Like (b), but @in contains only small integers: +=item c) + +Like (b), but @in contains only small integers: @out = grep(!$saw[$_]++, @in); -=item d) A way to do (b) without any loops or greps: +=item d) + +A way to do (b) without any loops or greps: undef %saw; @saw{@in} = (); @out = sort keys %saw; # remove sort if undesired -=item e) Like (d), but @in contains only small positive integers: +=item e) + +Like (d), but @in contains only small positive integers: undef @ary; @ary[@in] = @in; |