FILE MANAGEMENT
Getting file lists
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 ...
Get Perl To Python Migration now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.