thanks bart!
i used your idea and can confirm it works with the script below
on osX.
i would have liked to be able to supply the start-directory
(my $dir)
as argument on the commandline, do you know how i would do
that if possible and not mess up @ARGV at the same time?
thanks again
../allan
#!/usr/bin/perl -pi
BEGIN {
use Text::Tabs;
$tabstop = 4;
@ARGV = ();
my $global_delimiter = "/";
my $dir = "/Volumes/os9/Desktop Folder/test";
chdir($dir) or die $!;
&find($dir);
sub find {
my($dir, $func) = @_;
local (*FOLDER);
my(@subfiles, $file, $specfile);
opendir(FOLDER, $dir) or die $!;
@subfiles = readdir(FOLDER);
closedir(FOLDER);
foreach $file (@subfiles) {
next if $file =~ /^\.{1,2}$/;
my $specfile = $dir . $global_delimiter . $file;
if (-f $specfile) {
push @ARGV, $specfile;
}
if (-d $specfile) {
&find($specfile);
}
}
}
}
$_ = expand($_);
__END__
Bart Lateur wrote:
> A second approach would be to have just one script, fill @ARGV in a
> BEGIN block. Yeah, that looks like it would be the best approach.
>
> #!/usr/bin/perl -pi
> BEGIN {
> use File::Find;
> use Cwd;
> my @argv = @ARGV; @ARGV = ();
> find sub {
> push @ARGV, $File::Find::name if -f and /\.txt$/;
> }, @argv ? @argv : cwd;
> }
>
> s/(.*?)\t/$1.(' ' x (4-length($1)%4))/ge;
>
> UNTESTED!
>
> The idea is that you pass the path of the root directory(/-ies) on the
> command line, or it will pick the current working directory without
> arguments. It will fill @ARGV with a complete list of all found files.
> BTW any plain files in the command arguments get included too, if they
> match the pattern. That's a feature of File::Find.
>
> It does that in a BEGIN block, so this is run once, at the start of your
> script. The main body of the script is run using the -pi command line
> switches, so that part runs once for every line in the input files.
>
> HTH,
> Bart.