in reply to Remove whitespace between lines

You don't need to use #! /usr/bin/perl -w as well as use warnings; Here is my version. It looks as though you're on Windows so if you have further problems, try turning the slashes round.
#! /usr/bin/perl use strict; use warnings; #use lib "c:/strawberry/perl/site/lib"; my $files_dir = 'data'; my $write_dir = 'data/processed'; opendir (my $dir_handle, $files_dir); while (my $filename = readdir($dir_handle)) { next unless -f $files_dir.'/'.$filename; print "Procesing $filename\n"; open my $fh_in, '<', $files_dir.'/'.$filename or die "failed to open '$filename' for read"; open my $fh_out, '>', $write_dir.'/'.$filename or die "failed to open '$filename' for write"; my $count=0; while (my $line = <$fh_in>) { # print to output file only non-whitespace lines print $fh_out $line unless $line =~ /^\s*\n$/; ++$count; } print "$count lines read from $filename\n"; }
The STDIN in the middle was hanging up the entire program. There was also an unnecessary chomp and assignment of $line to variable $text. I have commented out the 'use lib' line as you shouldn't need that either. Try this and let me know if it works.