#!/usr/bin/perl
use strict;
use warnings;

# read in all of the paths to include
my @all;
while (<>) {
	chomp;
	push @all, glob;
}

my (%inc, %exc);
for (@all) {
	my @parts = split m{/};
	for (1..$#parts) {
		# include every path component up to the end
		# e.g.
		# /abc
		# /abc/def
		# /abc/def/ghi
		$inc{join "/", @parts[0..$_]}++;

		# exclude every other path component
		# e.g.
		# /abc/def/*
		# /abc/*
		# /*
		$exc{join "/", @parts[0..$_-1]}++;
	}
}

# include things from shortest-to-longest path
# exclude things from longest to shortest
print "+ $_\n" for sort keys %inc;
print "- $_/*\n" for reverse sort keys %exc;
