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
In reply to Re: Store regular expressions in a file.
by BrowserUk
in thread Store regular expressions in a file.
by yoda54
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |