use strict; use warnings; my $file_a = "Fit I" ; my $file_b = "Fit II" ; my $file_c = "Fit III" ; my @fits = ($file_a, $file_b, $file_c) ; show_fits() ; foreach my $f (@fits) { suck_this($f) ; } ; show_fits() ; foreach (@fits) { suck_this($_) ; } ; show_fits() ; sub show_fits { print "Fits: ", join(', ', map { defined($_) ? length($_) : 'undef' } @fits), "\n" ; } ; sub suck_this { my ($what) = @_ ; open my $FH, '<', \$what ; print " Read:" ; while (<$FH>) { s/\r/\\r/g ; s/\n/\\n/g ; print " '$_'" ; } ; print "\n" ; } ;