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

"please help me this time(by writing correct code) because today is last date of my code submission for college project"

Don't bother cheating, review the existing responses, fix it yourself.

  • Comment on Re^17: partial matching of lines in perl

Replies are listed 'Best First'.
Re^18: partial matching of lines in perl
by Sidd@786 (Initiate) on Jun 17, 2020 at 14:24 UTC
    #!/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"; } }
    A reply falls below the community's threshold of quality. You may see it by logging in.