Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Is there a better way.

by Roy Johnson (Monsignor)
on Feb 23, 2009 at 22:42 UTC ( #745850=note: print w/replies, xml ) Need Help??


in reply to Is there a better way.

@uploads = grep /$pattern/, @files; ?

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Is there a better way.
by Anonymous Monk on Feb 23, 2009 at 22:49 UTC
    Thanks I will give that a try.
Re^2: Is there a better way.
by afresh1 (Hermit) on Feb 25, 2009 at 21:34 UTC

    The way I normally do this is similar, but skips using the temporary @files array.

    opendir my $dh, $dir or die "Unable to opendir [$dir]: $!"; my @uploads = grep /$pattern/, readdir ($dh); closedir $dh;

    Sometimes I will add a map { "$dir/$_" } between = and grep, but it depends on the use.

    l8rZ,
    --
    andrew

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2023-03-26 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?