in reply to Using a regex saved in an environment variable
Now I want to do the same thing except put the regular expression in an environment variable:But that's not a regexp; that's an expression.export REX="/--Begin--/ && /--End--/" echo $REX /--Begin--/ && /--End--/
You can do the interpolation in the shell, so that Perl sees what you intent it to see:
Here, $REX is exposed to the shell, which sees the above as:perl -00 -ne 'print if '$REX file.txt
perl -00 -ne 'print if /--Begin--/ && /--End--/' file.txt
In Section
Seekers of Perl Wisdom