1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/perl # Historie use strict; use warnings; my $dirname = 'C:\temp'; opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n"; while((my $filename = readdir(DIR))) { next if -f $filename; print $filename."\n"; } closedir(DIR);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/perl use strict; use warnings; my $dirname = 'C:\temp'; opendir ( my $dh, $dirname ) || die "Error in opening dir $dirname: $!\n"; # fetch all filenames ending in .tif or .tiff my @tif_files = grep { m/\.tiff?$/ } readdir $dh; closedir $dh; print "In directory $dirname are these tif files:\n", join "\n", @tif_files, "\n";
1 2 3 4 5 6 7
use File::Find::Rule; my $dirname = 'C:/temp'; # find all the .tiff? files in $dirname my @files = File::Find::Rule->file() ->name( m{\.tiff?$} ) ->in( $dirname );
my @files = <*.tiff>;