Hi,
I was wondering if anyone can help me out. I wrote a perl script which I can run through text pad just fine, except I want to have the output replace the contents of the file I am working on and be able to undo it if I wish. I don't know if there is a way to do this, but if anyone could help it would be much appreciated. Right now the results go to the results window, but I want them to go to the file window without the message on the bottom saying that it has run successfully.
thanks
eric
running perl script
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
Andreas
RE: running perl script
Hello Eric,
in your tool settings, give the -i parameter followed by the extension to use for the temporary file:
perl -i.tmp c:\perl\MyPerlScript.pl $FILE
in your perl script, read from stdin and write to stdout:
while(<>) #read from stdin
{
#substitute or whatever you want to do with the line
print; #write to stdout
}
The -i switch tells perl to use the same file for input and output. This is done by creating a temporary file with the same name as the original file but the extension you provide.
HTH
Andreas
in your tool settings, give the -i parameter followed by the extension to use for the temporary file:
perl -i.tmp c:\perl\MyPerlScript.pl $FILE
in your perl script, read from stdin and write to stdout:
while(<>) #read from stdin
{
#substitute or whatever you want to do with the line
print; #write to stdout
}
The -i switch tells perl to use the same file for input and output. This is done by creating a temporary file with the same name as the original file but the extension you provide.
HTH
Andreas
-
Fabien
RE: running perl script
Hi
I'm trying to run perl scripts in textpad, and i created a tool/command for this, but i get the following errer:
'perl' is not recognized as an internal or external command,
operable program or batch file.
Tool completed with exit code 1
How should i configure textpad to run and view the result of the script, in the command result window ?
Thanks a lot
Fabien
I'm trying to run perl scripts in textpad, and i created a tool/command for this, but i get the following errer:
'perl' is not recognized as an internal or external command,
operable program or batch file.
Tool completed with exit code 1
How should i configure textpad to run and view the result of the script, in the command result window ?
Thanks a lot
Fabien