Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    
  2. or download this
    sub read_dir {
        my $dir = shift;
    
        if ( opendir( DIR, $dir ) ) {
    
  3. or download this
    if ( whatever ) {
        # ...
    }  else {
        # ...
    }
    
  4. 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;
    
  5. or download this
            my @tmp = grep !/^\.{1,2}$/, readdir(DIR);
    
  6. or download this
    my (@files,@dirs);
    for (readdir DIR) {
    ...
        push @files, $_ if -f;
        push @dirs, $_ if -d _;
    }
    
  7. or download this
            closedir( DIR );
    
  8. or download this
    sub glob_files {
        my ($dir, $recurse) = @_;
    
  9. or download this
            if (@$files) {    
                push @files, @$files;
            }
    
  10. or download this
            push @files, @$files;
    
  11. or download this
            recursion: {
                last unless $recurse;
    
  12. or download this
                while (@$dirs) {
                    my $d = shift (@$dirs);
    
  13. or download this
                for (@$dirs) {
    
  14. or download this
                    my @f = glob_files("$d", 1);
    
  15. or download this
        }else{
            return;
        }
    }
    
  16. or download this
        foreach $file (@files) {
            open FH, $file or
                die "Error opening [$file]: $!\n";
    
  17. or download this
            next unless ( -s $file > 9 );
    
  18. or download this
            read(FH, $data, 10) or
                die "Error reading from [$file]: $!\n";
    
  19. or download this
            if ( $data =~ /^BM/ ) {
                $type = 'BMP';
    ...
            }else {
                $type = undef;
            }
    
  20. or download this
        return @images if ( scalar (@images) );
        return;
    
  21. or download this
        return @images;
    
  22. or download this
    my (@files, @images);
    my $recurse = 1;
    
  23. or download this
    @files = glob_files($dir, $recurse);
    @images = find_images(@files);