jlope043 has asked for the wisdom of the Perl Monks concerning the following question:
Hello all, I am trying to copy my original file but add a space after my $find. I have ran the code but nothing seems to export and I can't figure out why. I have used this format before on my of my other scripts but this one I can't get to function properly.
use strict; for $find = "END OF EXPANDED DATA"; open (NEW, ">", "FILE_OUTPUT.txt" ) or die "could not open:$!"; open (FILE, "<", "FILE.txt") or die "could not open:$!"; while (<FILE>) { if (/$find/){ print NEW "\n"; } } close (FILE); close (NEW);
INPUT FILE:
LINE 1 LINE 2 LINE 3 END OF EXPANDED DATA LINE 4 LINE 5 LINE 6 LINE 7 END OF EXPANDED DATA LINE 8 LINE 9
OUTPUT FILE:
LINE 1 LINE 2 LINE 3 END OF EXPANDED DATA LINE 4 LINE 5 LINE 6 LINE 7 END OF EXPANDED DATA LINE 8 LINE 9
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Add Space after $Find
by choroba (Cardinal) on Jul 05, 2017 at 19:27 UTC | |
by Anonymous Monk on Jul 05, 2017 at 20:32 UTC | |
|
Re: Add Space after $Find
by thanos1983 (Parson) on Jul 06, 2017 at 08:58 UTC |