From bce0a42e9f6f150db18cbf2f8353d5561f08378e Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Mon, 3 Oct 2011 18:41:20 +0200 Subject: [PATCH] long whitespaces are now shortened to one character while golfing --- lib/Mo/Golf.pm | 3 +++ lib/Mo/import.pm | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Mo/Golf.pm b/lib/Mo/Golf.pm index aeee53c..05cbf4e 100644 --- a/lib/Mo/Golf.pm +++ b/lib/Mo/Golf.pm @@ -76,6 +76,9 @@ sub _finder_subs { duplicate_whitespace => sub { my ( $top, $current ) = @_; return 0 if !$current->isa( tok 'Whitespace' ); + + $current->set_content(' ') if 1 < length $current->content; + return 0 if !$current->next_token; return 0 if !$current->next_token->isa( tok 'Whitespace' ); return 1; diff --git a/lib/Mo/import.pm b/lib/Mo/import.pm index 65b07df..66efa19 100644 --- a/lib/Mo/import.pm +++ b/lib/Mo/import.pm @@ -1,3 +1,3 @@ package Mo::import;my$M="Mo::"; $VERSION=0.25; -my$i=\&import;*{$M.import}=sub{(@_==2 and not $_[1])?pop@_:@_==1 ?push@_,grep!/import/,@f:();goto&$i}; +my$i=\&import;*{$M.import}=sub{(@_==2 and not $_[1])?pop@_:@_==1 ?push@_,grep!/import/,@f:();goto&$i};