in reply to how to sort uniq $array[2]

Please read How do I post a question effectively?.

Below is your code reformatted for others to be able to help you:

#!/usr/bin/perl -w use strict; find_serv (); sub find_serv { @ARGV == 2 || die "usage: $0 INDEX_FILE '.com'\n"; my ( $INDEX_FILE, $com ) = @ARGV; my $list = "grep 'href=' $INDEX_FILE|" ; open (my $HAN, "$list" ) || die "Cannot open '$INDEX_FILE' because +:: $!"; while (<$HAN>) { chomp $_; my @array = split (/\//, $_); if ($array2 =~ /$com/ ){ my $sorted = $array2; system (sort -u $scalar); # - doesn't work #print "$_\n" for sort { versioncmp($a,$b) } $sorted; } } } #END sorted file should look like www.google.ie www.icq.com www.....