Skip to content

Instantly share code, notes, and snippets.

@lolicsystem
Created November 11, 2009 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lolicsystem/232151 to your computer and use it in GitHub Desktop.
Save lolicsystem/232151 to your computer and use it in GitHub Desktop.
anktagcloud.pl -- Ank Pixiv Tool で取得した絵のタグから、自分の性癖を知るためのスクリプト
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use feature ":5.10";
my $dbh = DBI->connect("dbi:SQLite:dbname=ankpixiv.sqlite",
undef,
undef,
{
AutoCommit => 0,
RaiseError => 1,
});
my %count;
eval {
my $ary_ref = $dbh->selectall_arrayref("SELECT tags FROM histories;");
for my $row (@$ary_ref) {
for (split ' ', $row->[0]) {
$count{$_}++;
}
}
};
if ($@) {
$dbh->disconnect;
die "Error: $@";
}
$dbh->disconnect or warn $!;
say "$count{$_}\t$_" for (sort {$count{$b} <=> $count{$a}} keys %count);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment