FreeBSD Ports Perl Modules

Summary

I have written two Perl modules which provide an easy-to-use interface to FreeBSD's Ports INDEX file. Full documentation is provided with the package. Please send any comments ideas to me at tom@FreeBSD.org.

Download

The latest version of these modules is 0.04, released on 13th January 2004.

Examples

The following examples display the capabilities of these modules:

# How many ports are there currently?
use FreeBSD::Ports::Index;
my $ports = tie my %port, 'FreeBSD::Ports::Index', '/usr/ports/INDEX';
my $count = scalar keys %port;
print "There are $count ports\n";
# Describe the ports maintained by tom@FreeBSD.org, sorted alphabetically
use FreeBSD::Ports::Index;
my $ports = tie my %port, 'FreeBSD::Ports::Index', '/usr/ports/INDEX';
$ports->maintainer('tom@FreeBSD.org');
$ports->sort('alpha');
foreach my $p (values %port) {
    print $p->as_ascii,"\n";
}
# List ports containing 'MPEG' in their comment and present in the
# 'audio' category?
use FreeBSD::Ports::Index;
my $ports = tie my %port, 'FreeBSD::Ports::Index', '/usr/ports/INDEX';
$ports->category('audio');
$ports->match('mpeg', 'COMMENT', 1);
foreach my $name (keys %port) {
    print "$name\n";
}

[Tom Hukins - FreeBSD Home Page]