Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Opendir and regex

by steves (Curate)
on Nov 16, 2004 at 18:17 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://408190]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found