Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regex variables with delimiters

by johngg (Canon)
on May 18, 2019 at 11:22 UTC ( [id://11100223]=note: print w/replies, xml ) Need Help??


in reply to Regex variables with delimiters

Perhaps you could read all of the lines from your second file, before starting to process the first, and construct a single regular expression with all of the strings you want to exclude.

johngg@shiraz:~/perl/utils$ perl -Mstrict -Mwarnings -E ' open my $file2FH, q{<}, \ <<__EOD2__ or die $!; /dumpx/DUMP4X/var/level6/55 /dumpx/DUMP4X/var/level7/58 __EOD2__ my $rxExcl = do { chomp( my @lines = <$file2FH> ); local $" = q{|}; qr{@lines}; }; close $file2FH or die $!; open my $file1FH, q{<}, \ <<__EOD1__ or die $!; /dev/sda3 6 Fri Apr 12 04:27:19 2019 +0100 /dumpx/DUMP3X/var/level6/ +47 81.34 MB /dev/sda4 6 Fri Apr 12 04:30:02 2019 +0100 /dumpx/DUMP4X/var/level6/ +55 86.53 MB /dev/sdb1 6 Fri Apr 12 04:31:47 2019 +0100 /dumpx/DUMP4X/var/level6/ +56 27.73 MB /dev/sdb2 6 Fri Apr 12 04:33:33 2019 +0100 /dumpx/DUMP4X/var/level7/ +58 57.32 MB __EOD1__ while ( <$file1FH> ) { print unless m{$rxExcl}; } close $file1FH or die $!;' /dev/sda3 6 Fri Apr 12 04:27:19 2019 +0100 /dumpx/DUMP3X/var/level6/ +47 81.34 MB /dev/sdb1 6 Fri Apr 12 04:31:47 2019 +0100 /dumpx/DUMP4X/var/level6/ +56 27.73 MB

I hope this is useful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Regex variables with delimiters
by AnomalousMonk (Archbishop) on May 18, 2019 at 14:52 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-19 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found