2005-03-04 (金) の 17:29 +0900 に Chris White さんは書きました: I've updated the script now, it has a better more functional layout than before (A large page script :). Re-cap of the install is here: > > http://dev.gentoo.org/~chriswhite/emerge_parse.pl > > In order to install this, you'll need to `g-cpan.pl Expect` in order to > get the Expect module (which interestingly enough also installs the dep > of IO::Tty). the main update was the parsing of category, package, and versions from ebuilds. The code of interest comes from these lines of code: sub package_nvsplit { $i=0; while($_[$i] !~ /^\d/) { $i++; } $package_end=$i-1; $pn=join("-",@_[0..$package_end]); $pv=@_[$i..$#package_array]; return $pn, $pv; } So for those interested in parsing out package versions and what not, this is basically how to go about it. First, you splitup the category and the package name+version (or $P). So... media-video/xine-lib-1.0 gets splitup into: media-video (category) and xine-lib-1.0 ($P). Now then, to get package and version seperation, one simply splits up $P with the - seperator. This gives us: xine lib 1.0 Which, a simple loop checks to see if we've hit a section that starts with a digit (the version number), and re-combines the values before it with -'s, giving us: $pv = 1.0 $pn = xine-lib So there you have it, the basis on seperation of package category, name, and version. Hopefully this will help those who wish to hack around a little get an idea of what's involved in the minute areas of portage. Note that while the code is perl, the concept is very language non-specific (I could do one in C.. but I'd rather save some of my sanity ;). Next stop will be getting USE flag descriptions in a more speedy manner than simple grep-ing. Please note that suggestions for improvement/comments/etc. are welcome, and I hope this turns into a nice informative developer's discussion. _big note_ I'd also like to thank Nick (carpaski) for his insight on the above code :). _big note_