open my $fh, "<", \$string or die "can't read from \$string: $!"; while (<$fh>) { ... }