Re: opendir()



compboy wrote:
DJ Stunks wrote:
compboy wrote:
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.

Use the File::Find core module.

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

.



Relevant Pages

  • Re: Rexxtacy
    ... I'd store the lines in an auxiliary area and never move them. ... Then I'd store and array of pointers contiguously and sort those. ... The Rexx-version uses the simplest bubble sort. ... CALL LineOut target,LineIn ...
    (comp.os.os2.programmer.misc)
  • Re: opendir()
    ... but how do you make the indentations so I will know what file is from ... I cant simply sort them cos they are not stored using array and if I ... as a recursive function. ...
    (perl.beginners)
  • Re: ordered list - sorta
    ... Is the simplest way to do this is to use an array and a temporary array? ... object to hold the rules and a store, perhaps a link-list, thus ... (ie, sort the "keys"), etc. ... Items belonging to ...
    (microsoft.public.vb.general.discussion)
  • Re: Data Type question / Sort
    ... A double can store numbers in this range: ... > I'm trying to prep some values for a multi-column sort in an array. ... > I've seen quick sort routines that can sort on a single value, ...
    (microsoft.public.excel.programming)
  • Re: using array in php
    ... caculate them then store them in array and sort them ... Prev by Date: ...
    (comp.lang.php)