in reply to Extracting data from file and modifying without making change in file.

Then don't apply a substitution, capture the (pattern for table) and evaluate. On a side note never use $`, $& and $' as they incur a large performance penalty on all regexes within your program.
my $last_match=0; while ($wholefile =~ /(pattern for table)/){ $newfile .= substr($wholefile, $last_match, ($last_match - $-[0])); $newfile.=eval{sub($1)}; # I think this is what you want to do #of course it will always return 0, #but that's what you have in the regex above. # perhaps you meant $newfile.= "sub($1)"; $last = $+[0]; }
The @-, $1, and @+ variables are a better way to manipulate your matches.

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."