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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^16: partial matching of lines in perl

Replies are listed 'Best First'.
Re^17: partial matching of lines in perl
by marto (Cardinal) on Jun 17, 2020 at 12:36 UTC

    "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.

      #!/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.