in reply to Handle bunch of lines as a Handle

Are you asking for something like
open(my $fh, '<', \$var);

That will allow you to read the contents of $var via file handle $fh.

By the way, please don't place your code in PRE tags. Use <p> at the start of paragraphs, and wrap computer text (programs, data, output, etc) in <c>...</c> tags.)