Solution 

#!/usr/bin/perl -nl
/\./;
$h{"$`.$'"}=1;
$h{"$`.M"}=1;
END { print join("\n", sort keys %h); }
#!/usr/bin/perl -nl
/\./;
@h{$_,"$`.M"}=1;
END { print join($\, sort keys %h); }