To read files from any directory first we have to access that directory. We have used opendir() to get that directory.Now to get all the files we have used readdir() so that all the files are listed in that directory.At last we have closed the directory.
Output:
Program Code:
# !/Perl/bin/perl
opendir (DIR,"C:/Perl64") ||die("Can't open the specified directory");
while($file=readdir (DIR)){
print("$file \n");
}
closedir (DIR);
# !/Perl/bin/perl
opendir (DIR,"C:/Perl64") ||die("Can't open the specified directory");
while($file=readdir (DIR)){
print("$file \n");
}
closedir (DIR);
Output:
0 comments:
Post a Comment