Remove duplicate value from an array in perl
#!/usr/bin/perl -w
use strict;
use warnings;
sub unique {
my %seen;
grep !$seen{$_}++, @_;
}
my @array = qw(one two three two three);
my @filtered = unique(@array);
print @filtered . "\n";
Output:-
one two three
You must be logged in to post a comment.