Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Store regular expressions in a file.

by BrowserUk (Pope)
on Nov 11, 2010 at 10:46 UTC ( #870807=note: print w/replies, xml ) Need Help??

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/


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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://870807]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2016-12-11 06:31 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (168 votes). Check out past polls.