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