Adding a perl script to automator
I have a script that do a search and replace in a file in Perl. This script work just fine when executed from the command line, but in automator it result in an empty file.
Any idea?
Eventually I want to replace the $file variable with the arguments passed from previous actions, but for now I'm "in debug mode" only.
Here is the basic of the script:
my $file="full Unix path to file";
my $search="that text";
my $replace="this text";
my @contents;
open (F, $file) || die "Can't open - $!\n";
@File = <F>;
close (F);
open (F, ">$file") || die "Can't open - $!\n";
for (@File) {
s/$search/$replace/g;
push(@contents,$_);
}
# Go to the beginning of the file
seek(F,0,0);
# Update the contents with the data from our array
print F (@contents);
close(F);
PowerBook 12 1.33 768meg RAM, Mac OS X (10.4.4), iLife 06