in reply to Re: Capturing and then opening multiple files
in thread Capturing and then opening multiple files
# Removing directory references '.' and '..' from the listing my $rmdir = shift (@file_list); my $rmdir2 = shift (@file_list);
Are you sure this works? I just tested and on my system . and .. are returned somewhere in the middle of the list at seemingly random positions, which means your code wouldn't be portable to my system and probably many Linux systems in general. Much better (File::Spec is a core module):
use File::Spec::Functions qw/no_upwards/; ... my @file_list = no_upwards readdir($dirhandle);
Or even better (one difference being that @file_list will contain Path::Class objects that include the directory):
use Path::Class qw/dir file/; my @file_list = dir($dirname)->children;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Capturing and then opening multiple files
by deedo (Novice) on Jul 05, 2017 at 11:51 UTC | |
by afoken (Chancellor) on Jul 06, 2017 at 06:53 UTC |