Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: reading directories

by dga (Hermit)
on Sep 14, 2001 at 21:10 UTC ( [id://112463]=note: print w/replies, xml ) Need Help??


in reply to reading directories

You could make an array of everything then grep out what you don't want.

#!/usr/bin/perl use strict; my(@t1)=dirarray("test1"); #get everything my(@t2)=grep !/^\./, dirarray("test2"); #get everything but dot files sub dirarray { my($dir)=@_; my $dh; opendir($dh, $dir) or die "$0: Cannot open $dir for listing: $!\n" +; my(@files)=readdir($dh) or die "$0: Can not list files in $dir: $! +\n"; return(@files); }

Then you can use the arrays as desired.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found