-----Original Message----- From: Ricardo SIGNES [mailto:[EMAIL PROTECTED] Sent: Friday, August 18, 2006 8:58 AM To: beginners@perl.org Subject: Re: recusrive listing
* "Smith, Derek" <[EMAIL PROTECTED]> [2006-08-17T10:52:16] > What module would be ideal for getting a recursive listing into an array > or hash? Your code, below, makes it look like you really mean "for getting a recursive directory listing." > I was looking at IO::All???? Is that a question? Do multiple question marks convert into a period or something? Here's a crappy little directory lister I wrote once: http://rjbs.manxome.org/hacks/perl/tree You could pretty easily turn that into a hash-builder. Instead of passing in an indent level, just pass in the directory name. Instead of printing, ********************************** Thank you for that code as I thought about using glob and grep, but found IO::All easier to manipulate. Yes I need to get a recursive dir listing which I did use IO::All. Yes that was a question after all I typed "?" right? : ) No period conversion. Typically multiple ??? marks in the English language has inherited dual meanings: 1) a question and 2) thinking out loud wanting feedback. Here is what I initially was using to grab all files, no dirs: snip.... push @NBlogs1, grep { $_ ne "." and $_ ne ".." and -f "$oneweekdir/$_" } readdir(DIR1); snip... then for another requirement I started using IO::All use IO::All; my $twoweekdir = io('/usr/openv/netbackup/logs'); my @twoweekdir_contents = $twoweekdir->all(0); foreach my $log (@twoweekdir_contents) { push @NBlogs2, $log if $log =~ /log.\d+/; } The infix deref operator $twoweekdir->all(0) means dive down subdirs as far as it can go. Do I really need to load ::All as opposed to just ::Dir? IO::All combines all of the best Perl IO modules into a single nifty object oriented interface to greatly simplify your everyday Perl IO idioms. It exports a single function called io, which returns a new IO::All object. And that object can do it all! The IO::All object is a proxy for IO::File, IO::Dir, IO::Socket, IO::String, Tie::File, File::Spec, File::Path and File::ReadBackwards; as well as all the DBM and MLDBM modules. You can use most of the methods found in these classes and in IO::Handle (which they inherit from). IO::All adds dozens of other helpful idiomatic methods including file stat and manipulation functions. IO::All is pluggable, and modules like IO::All::LWP and IO::All::Mailto add even more functionality. Optionally, every IO::All object can be tied to itself. This means that you can use most perl IO builtins on it: readline, <>, getc, print, printf, syswrite, sysread, close. The distinguishing magic of IO::All is that it will automatically open (and close) files, directories, sockets and other IO _________________________________________________ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk - Portuguese - Svenska: www.cardinalhealth.com/legal/email -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>