source: mp3-find/trunk/lib/MP3/Find/Util.pm @ 1

Last change on this file since 1 was 1, checked in by peter, 18 years ago

Initial import

File size: 794 bytes
Line 
1package MP3::Find::Util;
2
3use strict;
4use warnings;
5
6use base qw(Exporter);
7use vars qw(@EXPORT_OK);
8
9@EXPORT_OK = qw(build_query);
10
11sub build_query {
12    my @args = @_;
13   
14    # first find all the directories
15    my @dirs;
16    while (local $_ = shift @args) {
17        if (/^-/) {
18            # whoops, there's the beginning of the query
19            unshift @args, $_;
20            last;
21        } else {
22            push @dirs, $_;
23        }
24    }
25   
26    # now build the query hash
27    my %query;
28    my $field;
29    while (local $_ = shift @args) {
30        if (/^--?(.*)/) {
31            $field = uc $1;
32        } else {
33            $field ? push @{ $query{$field} }, $_ : die "Need a field name before value '$_'\n";
34        }
35    }
36   
37    return (\@dirs, \%query);
38}
39
40# module return
411;
Note: See TracBrowser for help on using the repository browser.