#!/usr/bin/perl -w use utf8; while (<>) { s/ /\n/g; # split lines on space ### you might want to add a some abbreviation protection here later s/([^\w\n])/\n$1\n/g; # separate punctuation from words s/\n\n+/\n/g; # clean up on multiple line breaks print; }