Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regex from a file

by choroba (Abbot)
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-08-22 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (156 votes), past polls