You are probably using too old a version of File::Find. Pre- and postprocess callbacks are a somewhat recent addition that entered the fray around Perl 5.6 IIRC.
A somewhat cleaned up version of your script:
#!/usr/bin/perl -w use strict; use constant OLD => "CPB.old"; use constant NEW => "CPB"; use File::Find; my $old_flag = 0; find ( { preprocess => sub { print "Pre-Processing\n"; $has_old = grep /\.old$/, @_; @_; }, wanted => sub {}, postprocess => sub { print "Post-Processing\n"; return unless $has_old; return unless rename NEW, OLD; open my $in, "<", OLD or die "Unable to open input CPB: $!"; open my $out, ">", NEW or die "Unable to open output CPB: $!"; while (<$in>) { s!^cat\t!cat\t/kat/src/all/bld_pipe.4go \\\n\t!; print $out $_; } } }, '/home/greg/mydir' );
Makeshifts last the longest.
In reply to Re: File::Find problem
by Aristotle
in thread File::Find problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |