go ahead... be a heretic | |
PerlMonks |
Loop through array or filehandleby markdibley (Sexton) |
on Sep 29, 2016 at 13:57 UTC ( [id://1172929]=perlquestion: print w/replies, xml ) | Need Help?? |
markdibley has asked for the wisdom of the Perl Monks concerning the following question:
Hello I have a subroutine that loops through some data in a file until it has found the correct outcome and then stops. I simply pass a filehandle reference to the subroutine to do it. However, I now have a new source of data that gives it to me in a smaller string. To apply the some routine I just need to split the data by \n and could pass the array reference to the subroutine. But is there a way to write a subroutine that takes either a filehandle ref or array ref to loop through? I am looking for a way that does not involve reading the whole file into a string (although I admit this may because I am old and started programming computers that had never heard of GB memory). Is it possible?
Back to
Seekers of Perl Wisdom
|
|