in reply to Sub routines

open my $ih, '<', $fin or die "cannot open $fin for reading, $!"; $ih =~ s/\n+/\n/g;
Substitution on a filehandle? It does not execute the substitution on the file content, though. You can verify it with
$ih =~ s/\n+/\n/g or warn "No subst\n";