View on
Mark Allen > RPM-Search-0.01 > RPM::Search



Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  


RPM::Search - Search all available RPMs


  # On (recent) RPM based systems
  my $db = RPM::Search->new();

  my @names = $db->search(qr/;
  # or
  @names = $db->search('perl-CGI-*');
  # or
  @names = $db->search('cpanminus');

  if ( @names ) {
    my $pkgs = join ", ", @names;
    `/usr/bin/yum -y install $pkgs`;
  else {
      print "No matching packages\n";


This module allows one to search the entire collection of RPMs available for a given installed Linux distribution that uses RPMs, not just listing the RPMs already installed on a system.

And frankly, have you tried using yum search?

Eventually, I plan to use this functionality to make a plugin for cpanminus to suggest vendor-supplied packages instead of building them "from scratch."


These are standard Perlish accessors: pass an argument to set it, pass no argument to get the current value.


Base location of the yum data (default: none)


Fully qualified path to the primary SQLite database (default: none)


DBI handle to the yum SQLite database



Make a new RPM::Search object. Will automatically search for an appropriate yum database and open a handle to the data set unless you pass valid arguments to the dbh and/or yum_primary_db attributes at construction time.

Returns a new RPM::Search object.


This method searches for an appropriate yum database starting at the location passed as a parameter. If no parameter is given, the method will use cache_base. If cache_base is not set, the method will use /var/cache/yum.

This call populates yum_primary_db.

The return value is boolean: true for success, false for failure.


This method opens a connection to the yum SQLite database. The DSN is constructed from the passed in parameter. If no parameter is passed in, the method will use yum_primary_db.

This method populates dbh.

This method causes a fatal error on any failure.


This method searches the RPM database using an optional pattern parameter. If no pattern is given, the method returns all available package names. (Note: This will be thousands of packages.)

The format of the pattern can be one of the following:

  • A regular expression using the qr// construct.
  • A SQL-ish wildcard expression using % and _
  • A filesystem like glob expression using ? and *
  • A scalar which must be a literal match for a package name in the database to return any results

The method returns an array of all matching package names (which may be zero results.) Undef is returned on errors.


Mark Allen, mrallen1 at yahoo dot com


Please report any bugs or feature requests to bug-rpm-search at, or through the web interface at

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

perldoc RPM::Search

You can also look for information at:


Copyright 2011 Mark Allen.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: