aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-02-24 10:17:37 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-02-24 10:17:37 +0000
commitad4031ad944a6ee247c953c7d3e8c98e27fe5f23 (patch)
tree1c2aaf39e600a4cb860aca7f8a91d66aae605ca0
parent7a40071bbbe445bce92b894ce4057ff2c24242a3 (diff)
downloadperlweeklychallenge-club-ad4031ad944a6ee247c953c7d3e8c98e27fe5f23.tar.gz
perlweeklychallenge-club-ad4031ad944a6ee247c953c7d3e8c98e27fe5f23.tar.bz2
perlweeklychallenge-club-ad4031ad944a6ee247c953c7d3e8c98e27fe5f23.zip
added a pretty print version of the code to display the numbers with "," and right aligned
-rw-r--r--challenge-153/james-smith/perl/ch-1.pl5
1 files changed, 5 insertions, 0 deletions
diff --git a/challenge-153/james-smith/perl/ch-1.pl b/challenge-153/james-smith/perl/ch-1.pl
index 5f6777bb9b..8a8c83f012 100644
--- a/challenge-153/james-smith/perl/ch-1.pl
+++ b/challenge-153/james-smith/perl/ch-1.pl
@@ -4,5 +4,10 @@ use strict;
use warnings;
use feature qw(say);
+## Normal print
say my $t = my $f = 1;
say $t += ($f*=$_) for 1..20;
+
+## Pretty print!! Single lining commify....
+printf "%26s\n", $t = $f = 1;
+printf "%26s\n", scalar reverse ( reverse ($t += ($f*=$_)) =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/gr ) for 1..20;