- or download this
use strict;
use warnings;
- or download this
sub read_dir {
my $dir = shift;
if ( opendir( DIR, $dir ) ) {
- or download this
if ( whatever ) {
# ...
} else {
# ...
}
- or download this
my @tmp = readdir(DIR);
my @files = map { "$dir/$_" } grep { !/^\.{1,2}$/ && -f "$dir/
+$_" } @tmp;
my @dirs = map { "$dir/$_" } grep { !/^\.{1,2}$/ && -d "$dir/
+$_" } @tmp;
- or download this
my @tmp = grep !/^\.{1,2}$/, readdir(DIR);
- or download this
my (@files,@dirs);
for (readdir DIR) {
...
push @files, $_ if -f;
push @dirs, $_ if -d _;
}
- or download this
closedir( DIR );
- or download this
sub glob_files {
my ($dir, $recurse) = @_;
- or download this
if (@$files) {
push @files, @$files;
}
- or download this
push @files, @$files;
- or download this
recursion: {
last unless $recurse;
- or download this
while (@$dirs) {
my $d = shift (@$dirs);
- or download this
for (@$dirs) {
- or download this
my @f = glob_files("$d", 1);
- or download this
}else{
return;
}
}
- or download this
foreach $file (@files) {
open FH, $file or
die "Error opening [$file]: $!\n";
- or download this
next unless ( -s $file > 9 );
- or download this
read(FH, $data, 10) or
die "Error reading from [$file]: $!\n";
- or download this
if ( $data =~ /^BM/ ) {
$type = 'BMP';
...
}else {
$type = undef;
}
- or download this
return @images if ( scalar (@images) );
return;
- or download this
return @images;
- or download this
my (@files, @images);
my $recurse = 1;
- or download this
@files = glob_files($dir, $recurse);
@images = find_images(@files);