I practiced to insert members to array and sort it then print out the member list.
use strict;
use warnings;
use Data::Dumper;
my $fh = \*DATA;
while(my $line = <$fh>) {
chomp($line);
$line =~ s/\s+//g;
push(my @ArrLines, $line);
my @SortedArr = sort @ArrLines;
foreach my $val (@SortedArr) {
print "$val\n";
}
}
__DATA__
A2B12,A8B15
A3B27
A5B14,A8B15,A5B18
I hope the output as below, but I found it doesn't work.
A2B12
A3B27
A5B14
A5B18
A8B15
Note: Remained only one of the duplicated item, like A8B15.
Appreciated for your comments and suggestions.