in reply to pretending that the contents of a variable are files

Perl's I/O layers include support for input and output from a scalar. When you read a record with <$fh>, you are reading the next line from $string.

open($fh, "<", \$string); # read only
the handle behaves in all respects like regular filehandles, so all I/O functions work, such as seek, truncate, sysread.

hm,now i am not so sure how this will help you but I hope it does

I found this trick from the cookbook receipt on perl.com.