#!/usr/bin/perl
use strict;

# depunctuate a file (for punctuation exercises)

# -------------------------------------
# mainline program
# - source is stdin, out is stdout
# -------------------------------------

# input file
my $inputfile = "STDIN";

# read entire file
my @lines = <$inputfile>;

# convert all whitespace runs to a single space
# lowercase everything

foreach my $line (@lines) {
  # convert multiwhitespace runs into single !
  $line =~ s/\s+/!/g;

  # convert multipunctuation runs into single space
  $line =~ s/[!,.?;:"УФ]+/ /g;

  # convert all uppercase to lowercase
  $line =~ tr/[A-Z]/[a-z]/;
  
  # output only if we have something to output
  if ($line ne " ") {
    print "$line";
  }
  
}



