go ahead... be a heretic | |
PerlMonks |
Re: replace multiple newline charactersby thanos1983 (Parson) |
on May 15, 2018 at 09:37 UTC ( [id://1214529]=note: print w/replies, xml ) | Need Help?? |
Hello g_speran, Fellow Monks have answered your question with multiple great answers. Just to add another minor answer using one of my favorite module(s) IO::All:
But why not reading the file line by line more efficiently and make it easier to simply keep the lines that contain something? Sample of code bellow:
I prefer to read my files from command line by using the eof function as it gives you the ability to read multiple files one after the other. For example perl test.pl in_1.txt in_2.txt etc... etc... Minor note, a similar question has been asked before in the Monastery (Removing empty string elements from an Array). Remember to search and read as much as possible for your problem it will really help you reading and trying alternative approaches. :) Hope this helps, BR.
Seeking for Perl wisdom...on the process of learning...not there...yet!
In Section
Seekers of Perl Wisdom
|
|