in reply to matching multiple line
#!/usr/bin/perl use strict; my $string_to_match = "I dont have money"; my $string_to_insert = "yes thats correct\nbut your should have\nmoney + with you\notherwise it is not\npossible\n"; open(INFILE, "basic.txt"); open(OUTFILE, ">>text.out"); while (<INFILE>) { unless (/$string_to_match/) { print OUTFILE $_; } else { print OUTFILE $_, $string_to_insert; } } close(OUTFILE); close(INFILE); 1;
|
|---|