aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-01-25 15:36:23 +0000
committerdrbaggy <js5@sanger.ac.uk>2021-01-25 15:36:23 +0000
commit87f2cca1c08b724332092b0ab73fcd522247af53 (patch)
treeb8a75fded67ec1c912f682a9978a9a5acb1978da
parent071408de692b446843bdc102d5b71acea69cfc92 (diff)
downloadperlweeklychallenge-club-87f2cca1c08b724332092b0ab73fcd522247af53.tar.gz
perlweeklychallenge-club-87f2cca1c08b724332092b0ab73fcd522247af53.tar.bz2
perlweeklychallenge-club-87f2cca1c08b724332092b0ab73fcd522247af53.zip
added some comments
-rw-r--r--challenge-097/james-smith/perl/ch-2.pl14
1 files changed, 11 insertions, 3 deletions
diff --git a/challenge-097/james-smith/perl/ch-2.pl b/challenge-097/james-smith/perl/ch-2.pl
index a995d64d5c..805b834d72 100644
--- a/challenge-097/james-smith/perl/ch-2.pl
+++ b/challenge-097/james-smith/perl/ch-2.pl
@@ -17,11 +17,19 @@ done_testing();
sub min_flips {
## Golf mode on...
+ ##
+ ## This was to use this to serve as an example of perl idioms that other programmers
+ ## may find it difficult to understand - and so I tried to put as many of them in relatively
+ ## short function....
+ ##
+ ## One statement functions are a lovely perl concept - even if they can get a bit difficult
+ ## to read....
+ ##
return [
map { local $/ =
- local $\ = ( $_[0] ^ ( substr $_[0], $_, $_[1]) x (length($_[0])/$_[1]) ) =~ tr/\x01/\x01/,
- !$_ || $_ < $/ ? $\ : $/,
- }
+ local $\ = ( $_[0] ^ ( substr $_[0], $_, $_[1]) x (length($_[0])/$_[1]) ) =~ tr/\x01/\x01/,
+ !$_ || $_ < $/ ? $\ : $/,
+ }
map { $_*$_[1] }
0 .. ( length($_[0])/$_[1] - 1 )
]->[-1];