What I have reads the whole content inside the file.
For example:
I have a file called “file.txt”
Inside that file
I have 200 lines of texts
I want to only to read
“The script is great good job” and
“The script is bad try agin”
And I want to print those two lines
To a file called “ file.out “
This is what I have so far and this reads out the whole text and prints the whole 200 lines of text.
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl -w
- #fh2.pl
- open FH, 'file.txt' or die "open failed: $!";
- open OUTFH, '> file.out' or die "open failed: $!";
- while (<FH>) {
- print OUTFH "Message: $_";
- }
- close FH;
- close OUTFH;