in reply to Dots appearing when opening a directory

maybe
next if $text =~ /^\.+$/;

(untested)

NB: this will also exclude files consisting of dots only.

otherwise

next if $text =~ /^\.\.?$/;

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)

PS: Je suis Charlie!