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

Re: Descending a directory tree, returning a list of files

by RonW (Parson)
on Jun 09, 2015 at 20:07 UTC ( [id://1129695]=note: print w/replies, xml ) Need Help??


in reply to Descending a directory tree, returning a list of files

You sub, _list_files, is expecting 2 parameters. You are only passing one. Since _list_files treats the second parameter as a reference, you need to pass a reference:

use strict; use warnings; my $cwd = getcwd; my @file_list; my $res = _list_files($cwd, \@file_list); # definition of _list_files($cwd omitted)

Replies are listed 'Best First'.
Re^2: Descending a directory tree, returning a list of files
by Rodster001 (Pilgrim) on Jun 09, 2015 at 20:19 UTC
    That didn't solve the problem. If I comment out the line where it descends a sub-directory (and calls itself):
    ## dir, decend if (-d $file) { ## sub-directory files #$files = _list_files($file, $files); }
    It works. Well, it returns all the files in the cwd as expected. But when that line is not commented out, if it finds a sub directory, it never returns to finish listing the files in the parent (the one we started in).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-23 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found