Created
July 5, 2012 06:46
-
-
Save inopinatus/3051871 to your computer and use it in GitHub Desktop.
Can't remember what this does, looks like it takes Debian package status as input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -l | |
# written in "hasty" perl, my apologies. | |
use Data::Dumper; | |
use strict; | |
use vars qw($p $m $n $d $k $h $l); | |
# excuse to abuse the schwartzian later on | |
$m = { Depends => '1', Recommends => '2[]', Suggests => '3()' }; $k = 'install ok installed'; $l = "\n"; | |
{ my ($i, $f, $v); do { if (/^$/ or eof) { $p->{$i->{Package}}{_} = $i if $i->{Status} eq $k; $i = {}; } else { if (/^\s/) { $i->{$f} .= "\n$_"; } else { ($f, $v) = split /: /; $i->{$f} = $v; } } } while (chomp($_ = <>)); } | |
my @foo = map { $p->{$1}{$_}{$n}++ while $d->{_}{$_} =~ /\s*([^ ,]+)[^,]*/g } keys %$m while ($n, $d) = each %$p; | |
print STDERR "@foo\n"; | |
# Gratuitous Schwartzian to waste memory and generally annoy | |
map { $n = $_, print "$n:", join(" ", map { (($h = $p->{$n}{$_->[0]}) ? $_->[2].join(",", keys %$h).$_->[3] : ()) } sort { $a->[1] <=> $b->[1] } map { [ $_, split //, $m->{$_} ] } keys %$m) } sort keys %$p; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment