aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-02-13 01:00:24 +0000
committerdrbaggy <js5@sanger.ac.uk>2021-02-13 01:00:24 +0000
commit3957a4fbac71408ac235fff57696f9bf84eea053 (patch)
tree278413012a17d2bc5174bf5ef357340a27a66769
parent5f7d54f31adafd003af9af147217eb745ee33c36 (diff)
downloadperlweeklychallenge-club-3957a4fbac71408ac235fff57696f9bf84eea053.tar.gz
perlweeklychallenge-club-3957a4fbac71408ac235fff57696f9bf84eea053.tar.bz2
perlweeklychallenge-club-3957a4fbac71408ac235fff57696f9bf84eea053.zip
golfed even harder!
-rw-r--r--challenge-097/james-smith/perl/ch-2.pl9
1 files changed, 5 insertions, 4 deletions
diff --git a/challenge-097/james-smith/perl/ch-2.pl b/challenge-097/james-smith/perl/ch-2.pl
index aa1f3cfb02..42e29e5a59 100644
--- a/challenge-097/james-smith/perl/ch-2.pl
+++ b/challenge-097/james-smith/perl/ch-2.pl
@@ -152,10 +152,11 @@ sub mf_1{[local$/=length$_[0],local$\=$//$_[1],map{$/=$_<$/?$_:$/}map{($_[0]^$_)
sub mf_2{[local$/=length$_[0],local$\=$//$_[1],map{$/=$_<$/?$_:$/}map{($_[0]^$_)
=~y/\1/\1/}map{$_ x$\}map{substr$_[0],$_,$_[1]}map{$_*$_[1]}0..$\-1]->[-1]}
-## Golf extra (less readable!) [at 135 characters] - 125 inside the curly braces..
-sub mf_g{[local$/=length$_[0],local$\=$//$_[1],map{$/=$_<$/?
-$_:$/}map{($_[0]^substr($_[0],$_*$_[1],$_[1])x$\)=~y/\1/\1/}
-0..$\-1]->[-1]}
+## Golf extra (less readable!) [at 125 characters] - 115 inside the curly braces..
+## but side effects as no longer localise $/ & $\
+sub mf_g{[$/=length$_[0],$\=$//$_[1],map{$/=$_<$/?$_:$/}map{
+($_[0]^substr($_[0],$_*$_[1],$_[1])x$\)=~y/\1/\1/}0..$\-1]->
+[-1]}
sub mf_3{[local$/=length$_[0],local$\=$//$_[1],map{$/=$_<$/?
$_:$/}map{($_[0]^$_)=~y/\1/\1/}map{$_ x$\}map{substr$_[0],$_