Re: opendir()
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 26 May 2006 13:13:55 -0700
compboy wrote:
DJ Stunks wrote:
compboy wrote:Use the File::Find core module.
does anyone know how to use opendir() in the recursive function?
I want to make a script to read a directory and the files inside the
directories
and display them. if there is any subdirectory, I want to call this
function again
as a recursive function.
but how do you make the indentations so I will know what file is from
what
directory? and how do you sort them?
I cant simply sort them cos they are not stored using array and if I
try to do
it, the directories and the files would be messed up.
another question here: this by using File::Find can I store the result
into an array?
First step: read the File::Find documentation -
http://search.cpan.org/~nwclark/perl-5.8.8/lib/File/Find.pm
Next, write a wanted() subroutine that does what you want each time it
gets to a file or a directory. You'll use these variables:
$File::Find::dir is the current directory name,
$_ is the current filename within that directory
$File::Find::name is the complete pathname to the file.
and yes, you could push() one of these onto an array if you wanted, or
store them in a hash, or print them out with some number of tabs, or
whatever...
Good luck,
-jp
.
- References:
- opendir()
- From: compboy
- Re: opendir()
- From: DJ Stunks
- Re: opendir()
- From: compboy
- opendir()
- Prev by Date: Re: opendir()
- Next by Date: Re: What are the differences between Perl and PHP when handling with Web pages
- Previous by thread: Re: opendir()
- Next by thread: How to assign a hash of array to another hash
- Index(es):
Relevant Pages
|