doubledecker has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
any ideas of how to get list of files matching part of filename. ex: get filenames sample.txt or sample123.txt
use strict; use warnings; use File::Basename; use Data::Dumper; my @files = glob(".* *"); my $dir = '/home/test'; foreach my $file ( @files ) { next if ( $file eq '.' or $file eq '..' ); my @matches = glob("$dir/$file*"); if ( @matches ) { print Dumper(@matches); } }
This isn't doing what i expected. Any ideas are appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get list of files matching part of file name
by RichardK (Parson) on Jul 11, 2012 at 12:37 UTC | |
by doubledecker (Scribe) on Jul 11, 2012 at 13:19 UTC | |
by Athanasius (Archbishop) on Jul 11, 2012 at 13:29 UTC | |
|
Re: get list of files matching part of file name
by zentara (Cardinal) on Jul 11, 2012 at 14:23 UTC | |
|
Re: get list of files matching part of file name
by Anonymous Monk on Jul 11, 2012 at 16:15 UTC | |
|
Re: get list of files matching part of file name
by Anonymous Monk on Jul 11, 2012 at 17:02 UTC |