Skip to Content
Programming PERL in the .NET Environment
book

Programming PERL in the .NET Environment

by Yevgeny Menaker, Michael Saltzman, Robert J. Oberg
September 2002
Intermediate to advanced content levelIntermediate to advanced
496 pages
10h
English
Addison-Wesley Professional
Content preview from Programming PERL in the .NET Environment

File Inquiry Operators

There may be many occasions where a programming task depends upon the type of one or more files. For example, you may need to know whether a name represents a file or whether a file is a directory. Perl has several operators that can help you toward these tasks. Table 3-3 shows some of these operators.

Table 3-3. Some File Inquiry Operators
OperatorMeaning
-eFile exists.
-zFile has zero size.
-sFile has nonzero size (returns size).
-fFile is a plain file.
-dFile is a directory.
-TFile is a text file.
-BFile is a binary file (opposite of –T).
-MAge of file in days

Here is a program that illustrates a few of these operators. See the folder FileStat.

 % type filestat.pl # # filestat.pl # print "Enter a filename "; chomp($fn = <STDIN>); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Sams Teach Yourself Perl in 21 Days, Second Edition

Sams Teach Yourself Perl in 21 Days, Second Edition

Laura Lemay, Rafe Colburn
Pro Perl

Pro Perl

Peter Wainwright

Publisher Resources

ISBN: 0130652067Purchase book