diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-05-11 00:45:10 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-05-11 00:45:10 +0100 |
| commit | 2e3ed7f3d442a7bc1854e005b55ce7c93ff1a053 (patch) | |
| tree | 63e30d8fcf3fe4b17ea94d2c789b107626970464 | |
| parent | 4a5a9f771502d7cabeea60829705ec6a50ea89db (diff) | |
| download | perlweeklychallenge-club-2e3ed7f3d442a7bc1854e005b55ce7c93ff1a053.tar.gz perlweeklychallenge-club-2e3ed7f3d442a7bc1854e005b55ce7c93ff1a053.tar.bz2 perlweeklychallenge-club-2e3ed7f3d442a7bc1854e005b55ce7c93ff1a053.zip | |
treat "." as ""
| -rw-r--r-- | challenge-112/james-smith/perl/ch-1.pl | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/challenge-112/james-smith/perl/ch-1.pl b/challenge-112/james-smith/perl/ch-1.pl index 28d6aa6f5e..b050bfd27c 100644 --- a/challenge-112/james-smith/perl/ch-1.pl +++ b/challenge-112/james-smith/perl/ch-1.pl @@ -8,6 +8,7 @@ use Test::More; is( can_path('/a/'), '/a' ); is( can_path('/a/b//c/'), '/a/b/c' ); +is( can_path('/a/./b/./c/'), '/a/b/c' ); is( can_path('/a/b/c/../..'), '/a' ); is( can_path('/a/b/../c/..'), '/a' ); is( can_path('/a/../b/../c/..'), '/' ); @@ -17,7 +18,7 @@ is( can_path('/a/../b/../c/../../..'), '/' ); done_testing(); sub can_path { - my $l = my @parts = grep { $_ ne '' } split m{/}, $_[0]; + my $l = my @parts = grep { $_ ne '' && $_ ne '.' } split m{/}, $_[0]; while(--$l>0) { if($parts[$l] eq '..' && $parts[$l-1] ne '..' ) { splice @parts, $l-1,2; |
