in reply to Regex from a file
You can build the regex from the lines read from the file:
Note: Make yourself familiar with the Scunthorpe_problem.#!/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 $!;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
|
---|
In Section
Seekers of Perl Wisdom