in reply to Remove whitespace between lines

Change your while loop:
while (my $line = <$fh_in>) { my $text = $line; chomp ($text); #Strip/remove whitespace between lines of text file; while (<STDIN>) { print if (!/^\s*$/); } print $fh_out "$text\n"; #Save stripped results; }
as follows:
while (my $line = <$fh_in>) { print $fh_out $line if (!/^\s*$/); }
Update: Sorry, I wrote that above message on my mobile device in the train commuting back to home, the train was arriving near my town, so I copied and pasted the code a bit to hastily. The above code should be:
while (my $line = <$fh_in>) { print $fh_out $line if $line !~ /^\s*$/; }
Update 2: I had not noticed when I wrote the first update above, but poj sent me a CB message proposing a very similar correction. Thanks to poj. Further update: I had also not seen that poj also posted the correction as an answer to your question, so that these updates end up not to be very useful...

Je suis Charlie.

Replies are listed 'Best First'.
Re^2: Remove whitespace between lines
by wrkrbeee (Scribe) on Feb 03, 2015 at 13:41 UTC
    Thank you for the simple solution. It gives me the error of "use of uninitialized value $_ in pattern match." Over my head for sure.
      while (my $line = <$fh_in>) { print $fh_out $line if ($line !~ /^\s*$/); }
        That's it, works great! Appreciate your interest and patience! :-)
Re^2: Remove whitespace between lines
by Anonymous Monk on Feb 03, 2015 at 13:58 UTC

    Here the pattern can be further simplified: print if /\S/;