arunhorne,
You have a prototype, which is a little different than a regular
subroutine. I will leave reading about the prototype to you and
how to get it to work with either arrays or references to arrays.
sub util_remove_duplicates {
my $array_ref = shift;
my %hash;
@hash{@{$array_ref}} = ();
return keys %hash;
}
There are a couple of things to point out.
Check out wantarray to see if the sub is being called in
list or scalar context - that way you can return the list or a ref
You do not need to undef the hash after you create it with my
You could reduce it even further, but it becomes less readable
Cheers - L~R