blob: 5d7a0157d51856a7250661b8c0241d6668cdf578 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/opt/perl/bin/perl
use 5.032;
use strict;
use warnings;
no warnings 'syntax';
use experimental 'signatures';
use experimental 'lexical_subs';
#
# See ../README.md
#
#
# Run as: perl ch-1.pl < input-file
#
while (<>) {
chomp;
my @parts = split /\/+/;
my @parts2;
foreach my $part (@parts) {
next if $part eq "." || $part eq "";
if ($part eq "..") {
pop @parts2;
next;
}
push @parts2 => $part;
}
say "/" . join "/" => @parts2;
}
|