http://www.perlmonks.org?node_id=870807


in reply to Store regular expressions in a file.

You could eval the code into existence. People decry it, but it is one thing that makes dynamic languages so powerful:

#!/usr/bin/perl use strict; use warnings; my $data = "duck"; while(<DATA>) { chomp; my $code = eval "sub{ \$_[0] =~ $_ }" // die $@; if( $code->( $data ) ) { print "$data\n"; } } __DATA__ s/duck/luck/

Produces:

c:\test>junk02 luck

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.