summaryrefslogtreecommitdiff
path: root/examples/updir.pl
blob: b8ba6f58f63f7048be16b160e7a5c6f8ea31bf8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl -w
# dwb: gu
# usage [n]gu goes up n directories in the current directory hierarchy

my $uri = $ARGV[0];
my $n = $ARGV[2];
$uri =~ s/[^\/]*$//;
for (my $i = 0; $i<$n; $i++) {
  last if $uri =~ m/https?:\/\/[^\/]+\/$/;
  $uri =~ s/[^\/]+\/$//;
}
print "open $uri\n";