=for about ************************************************* Author = Robert Gleeson Title = BSD::PkgSearcher E-mail = robert.gleeson3@gmail.com WWW = http://www.denlab.cn ************************************************* Description A Perl5 module that canused to interface with and search the Free,Net, and OpenBSD pkgsrc tree. =cut package BSD::PkgSearcher; use strict; use warnings; use Exporter; our @ISA = ('Exporter'); our @EXPORT = qw(&openindex &search); # variables global to the module. my @content; # This subroutine attempts to open the file(INDEX FILE); sub openindex { # Read input passed to openindex(); my %input = @_; # Store passed input in $INDEX. my $INDEX = $input{'INDEX_FILE'}; # Attempt to open the BSD INDEX file. open(IDX, '<', $INDEX) or return('0'); @content = ; close(IDX); return ('1'); } # This subroutine does the searching. sub search { # read input passed to search(); my %input = @_; # Three arrays that hold the search results, the results are push()'ed into them later on. my (@titles,@locations,@descriptions); # Three scalar variables that hold the input passed to search(); my ($title,$keyword,$case); # A variable that holds the regex to use for searching. my ($regex); # Check if the search has been passed CASE_SENSITIVE='value', if it hasn't default to '0' (case insensitive). if ( not exists($input{'CASE_SENSITIVE'} ) { $case = '0'; } else { $case = $input{'CASE_SENSITIVE'}; } # Check if the module was passed a title and/or a keyword to search for. $title = $input{'TITLE'} if (exists($input{'TITLE'}) ); $keyword = $input{'KEYWORD'} if(exists($input{'KEYWORD'}) ); # Loop through the INDEX file(@contents). foreach my $entry (@contents) { my ($port,$location,$description) = split(/\|/,$entry,3); return (@titles,@locations,@descriptions);; } } } 1;