Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by fishmonger (Hermit)
on Jun 11, 2012 at 23:24 UTC ( #975659=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://975659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2015-09-01 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (367 votes), past polls