Obviously this works fine, but what I really want to do is create a base program where the S/// operators and text file they act upon get read in from separate files and the the result is printed to an output file.

I know you can read in separate files for the S/// operator as in 'replacement word' file and 'substituted word' file and these then act on the text file, but the s/// operators are just simplifications for what I really want to do, which are RegEx.

So what the program should really read as is

$_ = "My cat can get very annoying at times but then that is to be expected seeing as he is nearly 80 years old";

RegEx; RegEx; RegEx; RegEx; RegEx; RegEx; RegEx; RegEx; etc.

print "$_\n";

So, I want the Regex to read in from a separate file and the example $_ to be read in from a separate file and then the read in RegEx to process the read in sample $_ with the output saved to another file.

At the command line, I want it to look something like

'perl base_prog.pl Regex.txt $_.txt'

(where Regex.txt and $_.txt will be specified)

I've tried with minimal success at the moment.

I have another idea where the base program opens a specified file with the Regex in it , which then get saved to another file which the gets executed itself as a valid script and continues the process by asking for the text file to be processed by the Regex.

This idea came about because I was told that reading in any operators into memory like the sample S/// operators in their full format does not allow them to process any other file as they as they cannot process this way.

The reason I want to specify the Regex file is becuse I want to be able to experiment with different combinations of Regex on text files which would mean different Regex files (for ease)

I think you're slightly confusing everyone with your description of what you want to do. When you say you want to store regexes in a file, I think that what you actually want is to store the patterns and the replacement strings for a set of substitution operators. If I'm wrong then please correct me.

It's perfectly possible to use variables as both the pattern and the replacement string in a substitution operator so you can write code like this.