in reply to Loop through array or filehandle
You can open a file handle on the string directly, see open
for example :-
use v5.22; use warnings; use autodie; my $mydata = "this\nthat\n"; open (my $fh, '<' , \$mydata); while (<$fh>) { print $_; } [download]