What's with all the options on that regexp? igcgxm?? And assuming $serviceName and $dll are strings, not regexp, you don't even quote your variables?
Your sorting before removing the duplicates, when it would be cheaper to sort after they have been removed (since you algorithm don't take into account the fact that the array is sorted).
join(" ", split " ", $elem) is very weird too.
When you want unique, use a hash!
sub RDup {
my %unique;
$unique{lc($_)} = $_ foreach @_;
return sort values %unique;
}
my @unique;
foreach $d (@dllExeLines) {
if ($d =~ /\Q$serviceName/) {
foreach $f (split(/,/, $d)) {
if ($f =~ /\Q$dll/i) {
push @unique, $dll;
}
}
}
}
@unique = RDup(@unique);