Complex Search/Replace Multiple Files Script Needed

I have a rather complicated search and replace I need to do among several dozen files and over a hundred occurrences. My site is written in PHP and throughout the old code, you will find things like

die("Operation Aborted due to.....");

For my new design skins for the site, I need to get rid of these statements and transform them into something like

echo "Operation Aborted due to.....";$h->endpage();exit;

So it really takes the first part: die(" and replaces it with Echo "
And then, on the same line only, replace: ); with ;$h->endpage();exit;

Is there anyway this can be done or am I really going to have to manually go through all pages to make these changes? Thanks.

UCCCC

---------- Post updated at 07:23 PM ---------- Previous update was at 07:11 PM ----------

So I figured out an solution...

I am simply going to do a search/replace on the Die function and rename the function to something new. I can then write my own function to do what I originally needed.

Now I find myself unable to discover where on this forum I can delete my post to save everyone time. :smiley: Well thanks for reading.

If you have found out the solution to problem, I hope you don't mind to post the solution as well, as that might help other users in the forum

I assume you are asking me to provide a more clear explanation of what I did. Okay.

From the linux command prompt, I ran the following commands, which perform a search and replace for die(" and also die (" and replace the die function with a new function name called diefunc for all my files of extension .php

perl -pi -w -e 's/die\("/diefunc\("/g;' *.php
perl -pi -w -e 's/die \("/diefunc \("/g;' *.php

Tutorial found here:
Linux - Search and replace over multiple files.

I then created a new function diefunc

function diefunc($text)
{
        global $h;
        echo $text;$h->endpage();exit;
}

My site has a global function .php file which is included in all my site pages, and it is there where I created this global function to be used on all the PHP pages now using the diefunc.