Hello,
I have no much idea how to do this in perl, but if you need the logic then I have a code where it is done in java.
Here is the code
Code:
import java.io.*;
public class DirListing{
private static void dirlist(String fname){
File fl = new File(fname);
String[] str = fl.list();
if(str == null){
System.out.println("Specified directory does not exist or is not a directory.");
System.exit(0);
}else{
for(int x = 0; x < str.length; x++){
String fileName = str[x];
System.out.println(fileName);
}
}
}
public static void main(String[] args){
switch(args.length){
case 0: System.out.println("Directory has not mentioned.");
System.exit(0);
case 1: dirlist(args[0]);
System.exit(0);
default : System.out.println("Multiple files are not allow.");
System.exit(0);
}
}
}
Bookmarks