open my $fh, 'uuu.txt'; my @new = map { s/\s+//g; } <$fh>; close $fh; open $fh '>uuu.txt'; print $fh @new; close $fh;