"be consistent" | |
PerlMonks |
Re: from txt file to arrayby thanos1983 (Parson) |
on Jun 22, 2017 at 09:13 UTC ( [id://1193264]=note: print w/replies, xml ) | Need Help?? |
Hello WisDomSeeKer34, Although the fellow Monks have replied to your question, I would like to add something extra. On your question you are asking on how to process one file, and the monks have provided you the answer. I would like to add here that while loop is faster than straight opening a file in an array but also to add using a hash to keep track of the content of multiple files. Sample of benchmark script and hash solution commented:
Maybe you are not interested in opening multiple files (today) but what about (tomorrow)? Update: One minor thing also to add here. Always always remember to close your file handles. Why? read this: Why do we need to close filehandles?. Update2: Minor thing updating @ARGV to $ARGV in Hash Of Arrays (HoA) solution. Hope this helps, BR.
Seeking for Perl wisdom...on the process of learning...not there...yet!
In Section
Seekers of Perl Wisdom
|
|