AtomicSoft.com Add power to your website!
Home Products Services Support Free
EasyData/SQL
easy-to-use web interface for SQL databases with countless features
AtomicDesk
help desk, FAQ, knowledge base, live support chat - all in one product
Custom programming
Installation
Documentation
HelpDesk
Libraries
Join our newsletter for information on software updates and new releases. You may unsubscribe at any time.



Click here to download plain text source code.

# subroutine name: list_dir
# Input:     absolute path to directory
#            files filter regexp [if empty, filter is ignored]
#            minumal age (in days since last modification time) [if empty,
#                         filter is ignored]
# Returns: array of found files (path included in filename)
sub list_dir {
    my ($dir, $regexp, $min_age) = @_;
    my @passed;
    if (opendir (LISTDIR, $dir)) {
        my @files = readdir(LISTDIR);            # Read in list of files in directory..
        closedir (LISTDIR);
        foreach my $file (@files) {
            if ($file ne "." && $file ne ".." && -f "$dir/$file" && ($regexp eq "" || $file =~ m/$regexp/s)) {
                if ($min_age) {
                    push (@passed, "$dir/$file") if (-M "$dir/$file" > $min_age);
                } else {
                    push (@passed, "$dir/$file");
                }
            }
        }
    }
    return @passed;
}
 
Copyright © 1999-2007 Atomicsoft Ltd. All Rights Reserved.