in reply to Dots appearing when opening a directory

. is "the current directory" and .. is "the parent directory". File::Spec provides the functions no_upwards, curdir and updir to help deal with them.

#!/usr/bin/env perl use warnings; use strict; use File::Spec::Functions qw/no_upwards curdir updir/; my $DIR = "/tmp/foo"; opendir my $dh1, $DIR or die $!; while(my $text = readdir $dh1) { next if $text eq updir || $text eq curdir; print "1: $text\n"; } closedir $dh1; opendir my $dh2, $DIR or die $!; my @files = no_upwards readdir $dh2; closedir $dh2; print "2: $_\n" for @files; __END__ 1: File.txt 2: File.txt

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.