in reply to Catching . .. in file listing

If you only want files, then just grab files and ignore all directories:
use strict; use warnings; opendir my $dh, $new_dir or die "Cannot open directory"; my @GPS = grep { -f "$new_dir/$_" } readdir($dh); closedir $dh;

Replies are listed 'Best First'.
Re^2: Catching . .. in file listing
by johngg (Canon) on May 01, 2009 at 17:19 UTC
    my @GPS = grep { -f "$new_dir/$_" } readdir($dh);

    It looks like the OP is on Windows so this is a bit OT but if you were on *nix you might want to consider adding and not -l "$new_dir/$_" into the grep depending on how you want to treat symbolic links.

    I hope this is of interest.

    Cheers,

    JohnGG