Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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/

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.


Comment on Re: Store regular expressions in a file.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://870807]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (15)
As of 2014-07-28 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls