Gentoo Archives: gentoo-dev

From: Aron Griffis <agriffis@g.o>
To: gentoo-dev@××××××××××××.org
Subject: Re: [gentoo-dev] Parsing emerge
Date: Sun, 06 Mar 2005 23:00:21
Message-Id: 20050306224919.GB13606@mustard.flatmonk.org
In Reply to: Re: [gentoo-dev] Parsing emerge by Chris White
1 Chris White wrote: [Sat Mar 05 2005, 12:11:24AM EST]
2 > sub package_nvsplit {
3 > $i=0;
4 > while($_[$i] !~ /^\d/) {
5 > $i++;
6 > }
7 > $package_end=$i-1;
8 > $pn=join("-",@_[0..$package_end]);
9 > $pv=@_[$i..$#package_array];
10 > return $pn, $pv;
11 > }
12
13 my ($cat, $name, $ver) = m{(.*)/(.*?)-(\d.*)};
14
15 There are much better regexes that will actually validate, but the
16 above regex does everything you described.
17
18 If you're interested in completed Perl code to correctly sort ebuilds
19 according to portage rules, see
20 http://dev.gentoo.org/~agriffis/darcs/skel/bashrc.funcs and search for
21 sortvers.
22
23 Regards,
24 Aron
25
26 --
27 Aron Griffis
28 Gentoo Linux Developer