more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As you did, you must open the file, then for every line of file you must check if starts with abc, then you can increment a variable or print out what you need.
Doing this way you will never load all the file lines but parse one by one. as someone noticed grep will work on arrays, so to use it you must load all the lines in one array @array = <FILE> which lead to memory issues if the file is big. Oha PS: perl have the poetry of next unless, which is so beauty instead of if(! COND) { continue } I can't avoid posting it! :) In reply to Re: find a string and count of its occurence in a text file
by oha
|
|