Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
Ports(3)	      User Contributed Perl Documentation	      Ports(3)

       FreeBSD::Ports -	Class for parsing FreeBSD's Ports INDEX

       This is a very early version of this module.  The interface to the
       class may be changed in the future.  The	documentation needs improving.

       Consequently, suggestions, comments and patches are extremely welcome!
       I believe the correct place to discuss this module is the freebsd-doc
       mailing list at

	 # Describe ports maintained by, sorted	alphabetically
	 use FreeBSD::Ports;
	 my $ports = tie my %port, 'FreeBSD::Ports', '/usr/ports/INDEX';
	 foreach my $p (values %port) {
	     print $p->as_ascii,"\n";

	 # How many ports are there currently?
	 use FreeBSD::Ports;
	 my $ports = tie my %port, 'FreeBSD::Ports', '/usr/ports/INDEX';
	 my $count = scalar keys %port;
	 print "There are $count ports\n";

	 # List	ports containing 'MPEG'	in their comment and present in	the
	 # 'audio' category?
	 use FreeBSD::Ports;
	 my $ports = tie my %port, 'FreeBSD::Ports', '/usr/ports/INDEX';
	 $ports->match('mpeg', 'COMMENT', 1);
	 foreach my $name (keys	%port) {
	     print "$name\n";

	 # Any ports which are under the 'www' or 'net'	category
	 use FreeBSD::Ports;
	 my $all_ports = tie my	%port, 'FreeBSD::Ports';
	 my $www_ports = tie my(%www_port), $all_ports;
	 my $net_ports = tie my(%net_port), $all_ports;
	 my %www_or_net_port;
	 while ( my($key, $value) = (each(%www_port), each(%net_port)) ) {
	     $www_or_net_port{$key} = $value;

       "FreeBSD::Ports"	is a simple interface to the INDEX file	used in
       FreeBSD's ports collection.

       This class uses Perl's tie interface.  See perltie for more

       For further information,	or to obtain the latest	version	of this
       module, see <URL:>.

       $ports =	tie my %port, $class, $filename
	   Read	and parse an INDEX file.  $filename is the name	of the file
	   containing the index.  If undefined,	/usr/ports/INDEX is used.

	   $class should be the	name of	the class ("FreeBSD::Ports") or
	   another "FreeBSD::Ports" object to be cloned.

	   %port is a hash whose keys are the names of the ports within	the
	   index.  The value of	each key is a FreeBSD::Ports::Port object.

	   $ports is an	object which can be accessed using the methods within
	   this	class.

	   Selects only	those ports whose maintainer's e-mail address is
	   $email.  Addresses are matched case insensitively.

	   Selects only	those ports whose primary category is $category_name.
	   The primary category	is the first category in which a port is
	   listed.  This represents the	directory under	/usr/ports in which a
	   port	is stored.  Category names are matched case insensitively.

	   Selects only	those ports which are present in the category named
	   $category_name.  In this case, category names are matched case

	   Selects only	those ports which have a run dependency	on the port
	   represented by $port.

	   $port is either the name of a port or a FreeBSD::Ports::Port

	   Selects only	those ports which have a build dependency on $port.

	   Selects those ports which have any type of dependency on $port.

       $ports->sort($method, $field)
	   Sorts the selected ports. $method specifies how the ports should be
	   sorted.  alpha means	the ports should be sorted alphabetically,
	   from	A to Z.	 rev_alpha means the ports should be sorted
	   alphabetically in reverse, from Z to	A.  Sorting is performed case

	   $field specifies which property of the ports	should be used to sort
	   by.	DISTRIBUTION_NAME is used if this value	is undefined.  One of
	   the following properties is usually selected:

	   COMMENT: Comment used to describe the port
	   DISTRIBUTION_NAME: Port's name
	   MAINTAINER: Maintainer's e-mail address
	   PRIMARY_CATEGORY: Port's primary category
       $ports->match($term, $field, $insensitive)
	   Selects only	those ports where $field matches $term.	 The values
	   which can be	used for $field	are the	same as	those used for the
	   "sort" method.  However, for	this method "COMMENT" is used if
	   $field is undefined.

	   $term is evaluated as a regular expression.	If $insensitive	is
	   defined, the	expression is evaluated	case insensitively.  If
	   undefined, case sensitive evalutaion	is used.

       This module is written by Tom Hukins <>.

       Thanks to Nik Clayton, Martin Heinen and	Lars Thegler for
       encouragement, assistance and patches.

       This module is distributed under	the same license as FreeBSD

       Hey! The	above document had some	coding errors, which are explained

       Around line 367:
	   You forgot a	'=back'	before '=head1'

perl v5.32.0			  2004-01-13			      Ports(3)


Want to link to this manual page? Use this URL:

home | help