입력을 배열로 받아 입력 배열 중 중복된 라인 제거한 배열을 출력.
Copy
sub
uniqueElements
{
my
(
$item
,
%seen
,
@result
);
foreach
$item
(
@_
) {
push
(
@result
,
$item
)
unless
$seen{$item}
++;
}
return
@result
;
}
usage
Copy
my
@out
= uniqueElements(
@lines
);
Perl
배열
제거
중복
Retrieved from https://hyacinth.kr:443/moniwiki/wiki.php/Perl/배열 중복 제거
last modified 2017-12-06 12:53:48