Perl program to read Files in a directory and print their names.

Perl program to read Files in a directory and print their names.

——————————————————————————————————————————

——————————————————————————————————————————

use strict;
use warnings;

my $dir_name = shift;

&Dir_Files (dir => $dir_name);
sub Dir_Files {
my %args = @_;
my $directory = $args{dir};
# my $directory = ‘c:\windows’;

opendir(DIR,$directory);
my @files = readdir(DIR);
closedir(DIR);
foreach(@files){
print $_,”\n”;
}
}

——————————————————————————————————————

——————————————————————————————————————

Advertisements

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: