use IO::Scalar; ### Open a handle on a string, read it line-by-line, then close it: $SH = new IO::Scalar \$var; while (<$SH>) { # ... } close $SH;