Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: perl script to print just directory names

by 2teez (Vicar)
on Dec 06, 2012 at 21:19 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-16 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found