Chapter 16. Interfacing with the System
When you finish this chapter, you should understand the following program:
use Cwd;use File::Spec;print cwd, "\n";my $dir = File::Spec->rootdir;chdir $dir;opendir(DIR, $dir) or die $!;my @files=readdir DIR;@files = sort {$a cmp$b} @files;foreach my $file (@files){ print "$file\n" if -r $file;}closedir DIR;chdir $ENV{HOME};print cwd, "\n";
16.1 System Calls
Those migrating from shell (or batch) programming to Perl often expect that a Perl script is like a shell script—just a sequence of UNIX/Linux (or MS-DOS) commands. However, system utilities are not accessed directly in ...
Get Perl by Example 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.