Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: readdir

by Speedy (Monk)
on Oct 29, 2002 at 19:49 UTC ( [id://208852]=note: print w/replies, xml ) Need Help??


in reply to filtering readdir()'s results

Perldoc is your friend here.

From your $dir path, looks like you are on windows. So go to a DOS prompt, enter:

perldoc -f readdir

and you will see by happy coincidence as the example in the last paragraph an answer to your question:

-------------------------

If you're planning to filetest the return values out of a "readdir", you'd better prepend the directory in question. Otherwise, because we didn't "chdir" there, it would have been testing the wrong file.

opendir(DIR, $some_dir) || die "can't opendir some_dir: $!"; @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR); closedir DIR;

------------

Just replace the ^\. with ^xxxx and your job is done, like:

opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!"; @xxxx = grep { /^xxxx/ && -f "$some_dir/$_" } readdir(DIR); closedir DIR; print "@xxxx";

Live in the moment

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://208852]
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-05-30 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found