#! /usr/local/bin/perl5 use LWP::Simple qw(get); use Text::Wrap qw(wrap $columns); $columns = 68; $SIG{"ALRM"} = sub { exit; }; alarm(3); # Just in case ###################################################### # Get the quote # ###################################################### $b = get("http://us.imdb.com/Games/randomquote"); ###################################################### # Strip extra crap off # ###################################################### $b =~ s#.*
#\n#gi;
@b = split(/\n/,$b);
@b = grep(/./,@b);
######################################################
# Get the last line; it is printed differently #
######################################################
$last = pop @b;
$last =~ s#from: #- #;
$last = ' 'x($columns-length($last)) . $last;
#############################################################
# For each line, if it looks like a quote, format it nicely #
# Otherwise just print it as is #
#############################################################
foreach $b (@b) {
if ($b =~ /^([a-z].*?: )/i) {
$left = $1;
$right = $b;
substr($right,0,length($left)) = "";
$blank = ' ' x length($left);
print wrap($left,$blank,$right);
print "\n";
} else {
print wrap(""," ",$b);
print "\n";
}
}
print $last . "\n";
__END__
from: "Our Mutual Friend" (1998) (mini)