#!/usr/bin/perl
use strict;
use warnings;

my @manual = map { $_ =~ m#/var/db/pkg/(\S+)/# } `grep manual-installation /var/db/pkg/*/+CONTENTS`;
print "manually installed : @manual\n";
my @unused = map { $_ =~ m#(\S+)\s#; my $p = $1; $p =~ tr#+#\\+#; $1 if (!grep (/$p/, @manual)) } `pkg_info -tq`;
print "unused : @unused\n";
