aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-05-11 10:02:26 +0100
committerdrbaggy <js5@sanger.ac.uk>2021-05-11 10:02:26 +0100
commit39d8dad796461c4dc82fc5ca63855c0789b1d962 (patch)
tree752fb2146cb66221be13d0c8d2289ecb8abeef9c
parent8ae16a10adaf60bb7b637921c443d4a24922fd08 (diff)
downloadperlweeklychallenge-club-39d8dad796461c4dc82fc5ca63855c0789b1d962.tar.gz
perlweeklychallenge-club-39d8dad796461c4dc82fc5ca63855c0789b1d962.tar.bz2
perlweeklychallenge-club-39d8dad796461c4dc82fc5ca63855c0789b1d962.zip
tidied into 3-liner (init, code, return) + compacted compact function
-rw-r--r--challenge-112/james-smith/perl/ch-1.pl6
1 files changed, 3 insertions, 3 deletions
diff --git a/challenge-112/james-smith/perl/ch-1.pl b/challenge-112/james-smith/perl/ch-1.pl
index c95592a90a..427b1bd0e5 100644
--- a/challenge-112/james-smith/perl/ch-1.pl
+++ b/challenge-112/james-smith/perl/ch-1.pl
@@ -64,9 +64,9 @@ sub canonical_path {
}
sub canonical_path_compact {
-my($p,@d)=(1,grep {''ne$_&&'.'ne$_}split/\//,shift);
-$d[$p]ne'..'?$p++:$p?splice@d,--$p,2:shift@d while$p<@d;
-'/'.join'/',@d;
+$a=1,@_=grep {''ne$_&&'.'ne$_}split/\//,shift;
+$_[$a]ne'..'?$a++:$a?splice@_,--$a,2:shift while$a<@_;
+'/'.join'/',@_;
}