November 2001
Beginner
320 pages
5h 53m
English
Perl provides two basic methods for getting file lists – you can use the special <spec> construct – for example < *.c> – or the preferred option now which is to use the glob() function to get a list. In either case the result is the same: a list of file names according to the file specification that you supply.
For example, to get a list of all the HTML files in a given directory:
@files = glob('*.html');
In Python, the glob() function in the glob module provides the same functionality:
import glob
files = glob.glob('*.html')
The glob module supports file expansion based on the Unix shell semantics which is the same as that supported by Perl in most circumstances. However, be aware that it's not identical ...
Read now
Unlock full access