in reply to Using a regex saved in an environment variable

Thanks Everyone. All the comments were very helpful. This works good:

perl -00 -ne 'print if eval $ENV{REX}' file.txt