my $fileContents; open my $scan, '<', \$fileContents; while (defined (my $block = <$scan>)) { ... } close $scan;