Now is the winter of our discontent
Made glorious summer by this sun of York;
And all the clouds that lour'd upon our house
In the deep bosom of the ocean buried.
Now are our brows bound with victorious wreaths;
Our bruised arms hung up for monuments;
Our stern alarums chang'd to merry meetings,
Our dreadful marches to delightful measures.
Grim-visag'd war hath smooth'd his wrinkled front;
And now, -- instead of mounting barbed steeds
To fright the souls of fearful adversaries, --
He capers nimbly in a lady's chamber
To the lascivious pleasing of a lute.
But I, -- that am not shap'd for sportive tricks,
Nor made to court an amorous looking-glass;
I, that am rudely stamp'd, and want love's majesty
To strut before a wanton ambling nymph;
I, that am curtail'd of this fair proportion,
Cheated of feature by dissembling nature,
Deform'd, unfinish'd, sent before my time
Into this breathing world scarce half made up,
And that so lamely and unfashionable
That dogs bark at me as I halt by them; --
Why, I, in this weak piping time of peace,
Have no delight to pass away the time,
Unless to spy my shadow in the sun,
And descant on mine own deformity:
And therefore, -- since I cannot prove a lover,
To entertain these fair well-spoken days, --
I am determined to prove a villain,
And hate the idle pleasures of these days.
Plots have I laid, inductions dangerous,
By drunken prophecies, libels, and dreams,
To set my brother Clarence and the king
In deadly hate the one against the other:
And if King Edward be as true and just
As I am subtle, false, and treacherous,
This day should Clarence closely be mew'd up, --
About a prophecy which says that G
Of Edward's heirs the murderer shall be.
Dive, thoughts, down to my soul: -- here Clarence comes.
####
use strict;
use warnings;
my $partLen = shift
or die qq{No part length supplied\n};
die qq{Part length not integer\n}
unless $partLen =~ m{^\d+$};
my $string = q{};
my $wordsFile = q{winter.txt};
open my $wordsFH, q{<}, $wordsFile
or die qq{open: $wordsFile: $!\n};
{
local $/;
$string = <$wordsFH>;
}
close $wordsFH
or die qq{close: $wordsFile: $!\n};
my @words = split m{\s+}, $string;
my $longestWord =
( sort { $b <=> $a } map { length } @words )[0];
die
qq{Part length too small to accomodate longest word\n}
if $partLen < $longestWord;
my @parts = ();
my $part = q{};
while ( my $word = shift @words )
{
$part = $word, next unless $part;
if ( length($part) + length($word) + 1 > $partLen )
{
push @parts, $part;
$part = $word;
}
else
{
$part .= qq{ $word};
}
}
push @parts, $part;
print qq{$_\n} for @parts;
####
Now is the winter of our
discontent Made glorious summer
by this sun of York; And all the
clouds that lour'd upon our house
In the deep bosom of the ocean
buried. Now are our brows bound
with victorious wreaths; Our
bruised arms hung up for
monuments; Our stern alarums
chang'd to merry meetings, Our
dreadful marches to delightful
measures. Grim-visag'd war hath
smooth'd his wrinkled front; And
now, -- instead of mounting
barbed steeds To fright the souls
of fearful adversaries, -- He
capers nimbly in a lady's chamber
To the lascivious pleasing of a
lute. But I, -- that am not
shap'd for sportive tricks, Nor
made to court an amorous
looking-glass; I, that am rudely
stamp'd, and want love's majesty
To strut before a wanton ambling
nymph; I, that am curtail'd of
this fair proportion, Cheated of
feature by dissembling nature,
Deform'd, unfinish'd, sent before
my time Into this breathing world
scarce half made up, And that so
lamely and unfashionable That
dogs bark at me as I halt by
them; -- Why, I, in this weak
piping time of peace, Have no
delight to pass away the time,
Unless to spy my shadow in the
sun, And descant on mine own
deformity: And therefore, --
since I cannot prove a lover, To
entertain these fair well-spoken
days, -- I am determined to prove
a villain, And hate the idle
pleasures of these days. Plots
have I laid, inductions
dangerous, By drunken prophecies,
libels, and dreams, To set my
brother Clarence and the king In
deadly hate the one against the
other: And if King Edward be as
true and just As I am subtle,
false, and treacherous, This day
should Clarence closely be mew'd
up, -- About a prophecy which
says that G Of Edward's heirs the
murderer shall be. Dive,
thoughts, down to my soul: --
here Clarence comes.