Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Friday, 3 May 2019

IOPP Program 6 B

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);

0 comments:

Post a Comment