#!/usr/bin/perl use warnings; use strict; binmode(STDIN,":utf8"); binmode(STDOUT,":utf8"); while() { $_ = " $_ "; # remove punctuation except apostrophe s//spacemark/g; # for scoring s/'/apostrophe/g; s/[[:punct:]]//g; s/apostrophe/'/g; s/spacemark//g; # for scoring # remove whitespace s/\s+/ /g; s/^\s+//; s/\s+$//; print "$_\n"; }