Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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";

Comment on Re: Opendir and regex
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2015-11-30 00:26 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (754 votes), past polls