Engineering Projects/Attendance/perl/Directory

From Wikiversity
Jump to navigation Jump to search

Listing the files in a directory is most easily done using a glob:

@files = <*>;
foreach $file (@files) {
  print "$file\n";
}

$pause = <>;

The * in <*> represents the current directory. The output on a windows machine looks like this:

There problems with this are:

can not tell file from directory explicitly
can not tell the type of file explicitly because file names can have spaces in them
no size information
no date information

Need to make these assumptions:

all files will have an extension which is after the period
names with out extensions are folders

Need to define a directory structure that is going to need to be crawled through looking for students.