Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: get list of files matching part of file name

by zentara (Archbishop)
on Jul 11, 2012 at 14:23 UTC ( #981125=note: print w/replies, xml ) Need Help??


in reply to get list of files matching part of file name

Here is a File::Find solution
#!/usr/bin/perl # non recursive case insensitive search down # thru current directory for pattern in filenames. use warnings; use strict; use File::Find; $|++; my $search = $ARGV[0] or die "need search pattern $!\n"; my $path = '.'; my $regex = qr/\Q$search\E/i; find (sub { #prevent recursion into subdirs my $n = ($File::Find::name) =~ tr!/!!; #count slashes in file return $File::Find::prune = 1 if ($n > 1); return if -d; # return unless (-f and -T ); # limit to text files print "$File::Find::name\n" if /$regex/; }, $path);

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981125]
help
Chatterbox?
Lady_Aleena just followed @metacpan on Twitter.
[atcroft]: I may just post a question about it later. *shrug*
[Lady_Aleena]: I wish I could have helped you further but I've never uploaded to cpan or metacpan so I don't know much.
[Lady_Aleena]: If metacpan had a pod checker too, I could check a pod I wrote with a module link there.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-05-27 04:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?