Okay, I've managed to get this to work perfectly with a regular match (//) - but when I try to do a substitution(s///), the pattern fails to match anything - and no substitution is done.
I'm calling the program like this: -r "s/matt/matthew/" -i -g, with the text 'matt, Matt'.
Here is the code that processes the substitution bit:
if($options{r}){
#variable grab, add flags to pattern if they exist.
my $pattern = $options{r};
$pattern .= 'g' if $options{g};
$pattern .= 'i' if $options{i};
$pattern .= 's' if $options{s};
#compile that stuff with eval
my $compd_pattern = eval "qr($pattern)" or die $@;
print "Please enter the text you wish to run the pattern on: ";
my $text = <STDIN>;
chomp $text;
#do work and display
if($text =~ $compd_pattern){
print $text;
}
else{
print "$pattern on \n\t{$text} Failed. ";
}
} #end R FLAG