diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-05-11 10:05:20 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-05-11 10:05:20 +0100 |
| commit | c103e8bdc1eebeb40e87a11b6cd24197f96d1035 (patch) | |
| tree | af026d0c3c672eccd74c9bd6269a192254c27f20 | |
| parent | 39d8dad796461c4dc82fc5ca63855c0789b1d962 (diff) | |
| download | perlweeklychallenge-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.pl | 3 |
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'/',@_; } - |
