Generally speaking,
# Remove duplicates from an array using a hash. # create starting array. @dupes = qw( a a b b b b a c b a c c b ); # use hash slice to create hash entries. @unique{@dupes} = (); # pretty much like: # foreach( @dupes ) { # $unique{$_} = undef; # } @unique = keys %unique; print "@unique\n"; #prints # c a b # if you want keys in order you can use # @unique = sort keys %unique;
TGI says moo
In reply to Re: Splitting output of a system command into an array
by TGI
in thread Splitting output of a system command into an array
by sKiBa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |