Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Regex from a file

by choroba (Canon)
on Sep 04, 2012 at 22:54 UTC ( #991700=note: print w/ replies, xml ) Need Help??

in reply to Regex from a file

You can build the regex from the lines read from the file:

#!/usr/bin/perl use warnings; use strict; open my $REG, '<', 'curse.txt' or die $!; (my $regex = join q(), <$REG>) =~ s/\n/|/g; $regex =~ s/\|$//; open my $FLT, '>', 'filtered.txt' or die $!; open my $TXT, '<', 'article.txt' or die $!; while (<$TXT>) { s/$regex/XXX/ig; print {$FLT} $_; } close $FLT or die $!;
Note: Make yourself familiar with the Scunthorpe_problem.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Comment on Re: Regex from a file
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-10-13 10:01 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (299 votes), past polls