Get a list of packages with no dependences in FreeBSD

This Perl script makes a list of packages in FreeBSD which have no dependences.

use warnings;
use strict;
use utf8;
use FindBin '$Bin';
my @pkgs = `pkg info`;
for (@pkgs) {
    my $name = $_;
    $name =~ s/^(\S+)\s+.*$/$1/g;
    my $r = `pkg info -r $name`;
    if ($r =~ /:.*$/) {
        print "$r\n";


Copyright © Ben Bullock 2009-2023. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. / Privacy / Disclaimer