From d237998a9d4e86b3addef32ec470083bfcfbca32 Mon Sep 17 00:00:00 2001 From: shabble Date: Wed, 11 Nov 2009 15:27:31 +0000 Subject: [PATCH] fixed Butts.pm to handle multi-liine inputs correctly --- Butts.pm | 2 +- butt-fortune.pl | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Butts.pm b/Butts.pm index f444865..f9cec96 100644 --- a/Butts.pm +++ b/Butts.pm @@ -136,7 +136,7 @@ sub is_meme { sub split_preserving_whitespace { my ($string) = @_; - my ($leading_ws, $remainder) = ($string =~ m/^(\s*)(.*)$/); + my ($leading_ws, $remainder) = ($string =~ m/^(\s*)(.*)$/s); $leading_ws //= ''; my @all_split = split(/(\s+)/, $remainder); diff --git a/butt-fortune.pl b/butt-fortune.pl index 848be92..7032148 100755 --- a/butt-fortune.pl +++ b/butt-fortune.pl @@ -25,10 +25,8 @@ POE::Component::Server::TCP->new my ($kernel, $session, $heap, $input) = @_[KERNEL, SESSION, HEAP, ARG0]; #print "Session ", $session->ID(), " got input: $input\n"; - my @fortune = `$fortune`; # ick. But Fortune.pm is shit. - foreach my $line (@fortune) { - $heap->{client}->put($butter->buttify_string($line)); - } + my $fortune_str = qx/$fortune/; # ick. But Fortune.pm is shit. + $heap->{client}->put($butter->buttify_string($fortune_str)); $kernel->yield("shutdown"); } );