Question:
Write a Perl script to list the contents of a directory.
Solution:
#!/usr/bin/perl
my $directory ='.';
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR)) {
print "$file\n";
}
closedir(DIR);
Write a Perl script to list the contents of a directory.
Solution:
#!/usr/bin/perl
my $directory ='.';
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR)) {
print "$file\n";
}
closedir(DIR);
0 comments:
Post a Comment