Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: perl script to print just directory names

by 2teez (Priest)
on Dec 06, 2012 at 21:19 UTC ( #1007656=note: print w/ replies, xml ) Need Help??


in reply to perl script to print just directory names

Hi Vijaay81,
As previously mentioned by toolic and others post before this. I also support using the module File::Find, which could reduce the number of lines of codes you write by half, if not more.
Something like so:

use strict; use warnings; use File::Find; find( sub { return if $_ eq '.' or $_ eq '..'; print $_, $/ if -d }, ' +.' ); #OR my @dir; find( sub { return if $_ eq '.' or $_ eq '..'; if (-d) { print $_, $/; # just to test push @dir, $_; # updated } }, '.' # this can be your "C:\Input" ); use DDP; p @dir;
Update:
Please, you would need module Data::Printer, installed for this line use DDP; p @dir; to work.
Hope this helps.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: perl script to print just directory names
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-08-23 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (171 votes), past polls