Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Store regular expressions in a file.

by mjscott2702 (Pilgrim)
on Nov 11, 2010 at 11:42 UTC ( #870830=note: print w/replies, xml ) Need Help??

in reply to Store regular expressions in a file.

If you just wanted to create regular expressions for matching from a file, you could use the qr quoting operator, but don't think that will work for substituting as you appear to want to do - as others have pointed out, you would probably have to use eval for that.

Replies are listed 'Best First'.
Re^2: Store regular expressions in a file.
by Anonymous Monk on Nov 11, 2010 at 11:52 UTC
    I see.


      This also works:

      #!/usr/bin/perl use strict; use warnings; my $data = "duck"; while(<DATA>) { chomp; my( $find, $replace ) = split ' ', $_, 2; if( $data =~ s[\Q$find][$replace]e ) { print "$data\n"; } } __DATA__ duck 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://870830]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-10-18 21:34 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (250 votes). Check out past polls.