Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: listing all subdirectories of directory into file

by jdrago999 (Pilgrim)
on Jun 08, 2012 at 17:23 UTC ( #975210=note: print w/ replies, xml ) Need Help??


in reply to Re^3: listing all subdirectories of directory into file
in thread listing all subdirectories of directory into file

Why open and close $out every time?

#!/usr/bin/env perl use Modern::Perl; use File::Find; # $out is used within w(): open my $out, '>>', 'list' or die $!; sub w { if( -d $_ ){ print $out "$_\n"; } } File::Find::find(\&w, '.');


Comment on Re^4: listing all subdirectories of directory into file
Download Code
Replies are listed 'Best First'.
Re^5: listing all subdirectories of directory into file
by aaron_baugher (Curate) on Jun 08, 2012 at 22:35 UTC

    If you look at his spec, he wants more than one "out" file. In each directory, he wants a file named 'list' that contains a list of every subdirectory of that directory. So in a directory structure like the following, you would get 'list' files like so:

    $ find . -ls|cut -b14-24,68- drwxr-xr-x . drwxr-xr-x ./a -rw-r--r-- ./a/list drwxr-xr-x ./a/d drwxr-xr-x ./a/c drwxr-xr-x ./b -rw-r--r-- ./list $ cat list a b $ cat a/list c d

    Aaron B.
    Available for small or large Perl jobs; see my home node.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2015-07-29 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls