in reply to Re^17: partial matching of lines in perl
in thread partial matching of lines in perl

#!/usr/bin/perl use warnings; use strict; my $file1 = 'C:/Users/Siddharth/Desktop/our.txt'; my $file2 = 'C:/Users/Siddharth/Desktop/my.txt'; my $search_file = ""; open(my $fh2, "<$file2"); while(my $line = <$fh2>) { $search_file .= $line; } open(my $fh1, "<$file1"); while(my $line = <$fh1>) { chomp($line); if($line =~ m/\w+\s+(.*)/) { my $search_string = quotemeta("$1"); if($search_file =~ m/(.*$search_string.*)/) { } else { print " $line\n"; } } else { print "Invalid line: $line\n"; } }

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.