http://www.perlmonks.org?node_id=975659


in reply to How to read files in a directory, directory path to be given through CMD

#!/usr/bin/perl use 5.10.0; use strict; use warnings; print "Enter a directory: "; chomp(my $dir = <>); $dir =~ s!(/|\\)$!!; while (my $entry = <$dir/*>) { my $type = -f $entry ? 'a file' : -d $entry ? 'a dir' : 'unknown'; say "$entry is $type"; }
  • Comment on Re: How to read files in a directory, directory path to be given through CMD
  • Download Code