in reply to regex for rpm: name, version, release, arch

I am not sure myself sometimes where version becomes release. What about this one?:
#!/usr/bin/perl use warnings; use strict; use Text::Table; my $tb = Text::Table->new(qw/NAME VERSION RELEASE ARCH/); while(<DATA>) { $tb->load( [ /^(.*)-(.*)-(.*)\.(.*)$/ ] ); } print $tb; __DATA__ fipscheck-1.2.0-1.el5.x86_64 iptables-ipv6-1.3.5-5.3.el5_4.1.x86_64 libXi-1.0.1-4.el5_4.i386 perl-Carp-Clan-5.3-1.2.1.noarch rpm-build-4.6.1-2.el5.x86_64
Output:
NAME VERSION RELEASE ARCH fipscheck 1.2.0 1.el5 x86_64 iptables-ipv6 1.3.5 5.3.el5_4.1 x86_64 libXi 1.0.1 4.el5_4 i386 perl-Carp-Clan 5.3 1.2.1 noarch rpm-build 4.6.1 2.el5 x86_64
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: regex for rpm: name, version, release, arch
by Anonymous Monk on Aug 31, 2012 at 15:06 UTC
    Can you not use rpm queryformat option to do all the work for you?
    rpm -qa --qf "%{n},%{v},%{r},%{arch}\n"