in reply to Multiple file input into a perl script
It depends. How do you find all those files? If you have them in a text file, read them from that text file:
use strict; my $filename = 'my_textfile.txt'; open my $fh, $filename or die "Couldn't read '$filename': $!"; chomp @ARGV = <$fh>; print "Processing $_" for @ARGV;
If they all are below a certain directory, use File::Find:
use strict; use File::Find; my $directory = '/home/kelder/files'; find(sub { push @ARGV, $File::Find::name; }, $directory ); print "Processing $_" for @ARGV;
If you want to use a shell glob pattern, you can prevent the shell from expanding it and do the expansion in Perl:
use strict; use File::DosGlob qw(bsd_glob); # to get sane whitespace semantics my $pattern = '/home/kelder/files/*.txt'; @ARGV = glob $pattern; print "Processing $_" for @ARGV;
If you have the list in some other fashion, you'll have to tell us, but the basic pattern remains.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multiple file input into a perl script
by kelder (Novice) on Sep 30, 2008 at 19:01 UTC | |
by Corion (Patriarch) on Sep 30, 2008 at 19:47 UTC | |
by broomduster (Priest) on Sep 30, 2008 at 22:11 UTC | |
by Corion (Patriarch) on Oct 01, 2008 at 05:42 UTC | |
by broomduster (Priest) on Oct 01, 2008 at 12:51 UTC | |
|
Re^2: Multiple file input into a perl script
by kelder (Novice) on Sep 30, 2008 at 19:53 UTC | |
by Corion (Patriarch) on Sep 30, 2008 at 19:58 UTC | |
by kelder (Novice) on Sep 30, 2008 at 20:25 UTC | |
by Corion (Patriarch) on Sep 30, 2008 at 20:33 UTC |