 |
|  |
 |
|
Mercator
|
 |
Sorekara no Nanimo
Jan 1970 time: 06:22
|
|
quote: Originally posted by Ramo
Mercator, I just installed Active Perl. Now, how would I run your script? |
I'm assuming your formulas are in a text file (or multiple files), with a formula preferably on one line (or at least not having a line break in between one such power construction)...
The quickest way is to simply type it in on the command-line:
code: perl -pi.bak -e"s/(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)/pow($1,$2)/g;" your_formula_filename(s)
That'll perform a global search/replace and will even create backups, with an added .bak extension.
If you more conveniently want to save it as a perl script (which does exactly the same), so you can use it later. Create a file that looks like this:
code: #!/Perl/bin/perl.exe -pi.bak
s/(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)/pow($1,$2)/g;
Make sure the first line matches your actual Perl path.
You'd call that script like this:
code: perl the_perl_script formula_file1 formula_file2
*cough* And I'm a bit late with this, but you could achieve the same with a text editor supporting Perl regular expressions, like Arachnophilia. In that case you'd simply open the file and replace all:
code: (\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)
by:
code: pow($1,$2)
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:22. Apolyton Time is 00:22. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|