Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Opendir and regex

by steves (Curate)
on Nov 16, 2004 at 18:17 UTC ( #408190=note: print w/replies, xml ) Need Help??


in reply to Opendir and regex

Either of these work in a directory where I have some *.pm files and a bunch of others:

use strict; my $pattern = '\.pm$'; opendir(TARGET, ".") or die "Can't open current directory: $!"; # First try my @targets = grep(/$pattern/, readdir TARGET); print join("\n", @targets), "\n\n"; # Second try rewinddir(TARGET); @targets = grep {/$pattern/} readdir TARGET; print join("\n", @targets), "\n\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://408190]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2016-12-10 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (162 votes). Check out past polls.