in reply to partial matching of lines in perl
use strict; use warnings; my $file1 = \<<"END1"; he is man don't you what goes on END1 my $file2 = \<<"END2"; he is what are try to do END2 open my $h2, '<', $file2 or die "cannot open file2"; my @a2 = <$h2>; close $h2; chomp @a2; my $match = join '|', @a2; $match = qr/$match/; open my $h1, '<', $file1 or die "cannot open file1"; my @a1 = <$h1>; close $h1; print grep {$_ =~ $match} @a1;
OUTPUT:
he is man
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: partial matching of lines in perl
by AnomalousMonk (Archbishop) on Jun 13, 2020 at 06:54 UTC | |
|
Re^2: partial matching of lines in perl
by Sidd@786 (Initiate) on Jun 15, 2020 at 08:24 UTC | |
by AnomalousMonk (Archbishop) on Jun 15, 2020 at 10:46 UTC | |
by AnomalousMonk (Archbishop) on Jun 15, 2020 at 09:07 UTC | |
by Sidd@786 (Initiate) on Jun 15, 2020 at 10:13 UTC | |
by hippo (Archbishop) on Jun 15, 2020 at 11:03 UTC | |
by Sidd@786 (Initiate) on Jun 15, 2020 at 10:41 UTC | |
by AnomalousMonk (Archbishop) on Jun 15, 2020 at 11:05 UTC | |
by soonix (Chancellor) on Jun 15, 2020 at 11:35 UTC | |
by Sidd@786 (Initiate) on Jun 15, 2020 at 13:40 UTC | |
| |
by BillKSmith (Monsignor) on Jun 16, 2020 at 15:50 UTC | |
by AnomalousMonk (Archbishop) on Jun 16, 2020 at 16:25 UTC |