use strict; use warnings; my $file1Str = <; close $fileIn; for my $secFile ($file2Str, $file3Str) { open my $secIn, '<', \$secFile; print "Sec: $_" for <$secIn>; }