in reply to Fileopening question
This is the sort of thing I usually use for such purposes. Note this is recursive and therefore will search subdirectories also. :-)
#!/usr/bin/perl -w # Recurse directories to find .txt files use strict; use File::Find; my $file = ''; my $dir = ''; @ARGV = qw(.) unless @ARGV; # current dir unless otherwise specified $dir = shift @ARGV; sub process_file { return unless -f; #skip directories $file = $_; if ($file =~ m/\.(txt)/si) { # do stuff here } } find(\&process_file, $dir);
HTH,
Update: Deleted a spurious line from the code. The original is from an example on recursive editing, and I stripped some (but not all) of the non-relevant code. Oops. ;-)
|
|---|