#!/usr/bin/perl use strict; use warnings; use List::Compare; my ($raw, @master, @sources); open LIST, 'slidelist'; while ($raw = ) { next if ($raw =~ /^\s*$/ or $raw =~ /^#/); # no comments or blanks next unless ($raw =~ /\.slide\.txt$/); chomp $raw; push(@master, "texts/$raw"); } close LIST; opendir DIR, 'texts'; @sources = map {"texts/$_"} grep {/\.slide\.txt$/} readdir DIR; closedir DIR; my $lc = List::Compare->new(\@master, \@sources); my $LR = $lc->is_LsubsetR; unless ($LR) { print "These files, though listed in 'slidelist', are not found in 'texts' directory.\n\n"; print " $_\n" for ($lc->get_unique()); print "\n"; print "Edit 'slidelist' as needed and re-run script.\n"; exit (0); } my @unused = $lc->get_complement; open(UNUSED, ">unused"); print UNUSED "Files currently unused:\n"; if (scalar(@unused)) { print UNUSED " $_\n" for (sort @unused); print "There are unused files; see 'texts/unused'.\n"; } else { print UNUSED " [None.]\n"; print "There are no unused files.\n"; } close(UNUSED);