develooper Front page | perl.perl5.porters | Postings from January 2015

Re: [perl #123691] Feature: A variation of glob() which uses regexps

Thread Previous | Thread Next
From:
Victor Porton
Date:
January 29, 2015 13:33
Subject:
Re: [perl #123691] Feature: A variation of glob() which uses regexps
Message ID:
7449461422538381@web14g.yandex.ru
29.01.2015, 13:51, "James E Keenan via RT" <perlbug-followup@perl.org>:
> On Wed Jan 28 10:39:13 2015, porton@narod.ru wrote:
>>  This is a bug report for perl from porton@narod.ru,
>>  generated with the help of perlbug 1.40 running under perl 5.20.1.
>>
>>  -----------------------------------------------------------------
>>  I suggest to add to Perl core a routine similar to glob(), but
>>  using regexps instead of globs.
>
> But that functionality already exists, does it not?
>
> (untested)
> #####
> opendir my $DIR, 'some/directory' or die;
> my @files = grep { m/some_pattern/ } readdir $DIR;
> closedir or die;
> #####

It is better to do it in one line rather than three ones.

--
Victor Porton - http://portonvictor.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About