#!/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"; }
In reply to Re: How to read files in a directory, directory path to be given through CMD
by fishmonger
in thread How to read files in a directory, directory path to be given through CMD
by ckj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |