#!/usr/bin/perl

undef $/;

my $text = <>;

$text =~ s/(\w)\s+([^\w])/$1$2/g;
$text =~ s/([^\w])\s+/$1/g;

print $text;
