sub contents { open (FH, "< $FileInfoName") or die "Can't open $FileInfoName for read: $!"; my @lines = ; # return @lines; # 1st problem: in scalar context, number of lines is returned # 2nd problem: next line is never reached close FH or die "Cannot close $FileInfoName: $!"; return join("", @lines); # fix: one big string with all lines concatenated # See also File::Slurp }