#!/usr/bin/perl -w
# This script is part of the NoonQuilt project:
#
#
#
# © Ali Graham, 1998
#
# (See makeQuilt.pl for the version history, etc.)
#
# Start of nq_dirstuff.pl (Various file/directory stuff)
# make sure this is syntactically clear....
use strict; use English;
# ... and running under Perl5
require 5.001;
# Start of nqds_getDirList(directory_name)
sub nqds_getDirList {
This code reads the list of files from a directory and then
checks that none of them match '.' or '..', the Unix directory
entries which mean 'current directory' and 'parent directory'.
It passes the cleaned list back as its return value.
if ( opendir(NQDS_GDLDIR, $ARG[0]) ) {
my @file_list = readdir(NQDS_GDLDIR);
closedir(NQDS_GDLDIR);
my @checked_list; my $checked_count = 0;
foreach my $file (@file_list) {
# skip Unix directory entries, if found
if (($file eq ".") || ($file eq "..")) { next; }
$checked_list[$checked_count] = $file;
$checked_count = $checked_count + 1;
}
return @checked_list;
} else {
# warn of failure
return 0;
}
}
# End of nqds_getDirList(directory_name)
# required return code
1;
# End of nq_dirstuff.pl
|