Skip to content

Instantly share code, notes, and snippets.

@eru
Created July 24, 2012 15:13
Show Gist options
  • Save eru/3170582 to your computer and use it in GitHub Desktop.
Save eru/3170582 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use DBIx::Simple;
# iPhone アプリの「連続バーコードリーダー」
# http://itunes.apple.com/jp/app/lian-xubakodorida/id482287887?mt=8
# を使って,書籍のバーコードを読み取り,読み取り結果が保存されているDBから
# ISBNコードのみを取得するスクリプト
# これを使って,コミックダッシュなどに登録を行える
# DB 接続
my $db = DBIx::Simple->connect('dbi:SQLite:dbname=./Barcode.sqlite') or die DBIx::Simple->error;
# バーコード取得
my $res = $db->select('ZABSBARCODE', 'ZSCANDATA');
my @asin = ();
while (my $row = $res->list) {
if ($row =~ /^9784\d+/) {
push(@asin, $row);
}
}
# ソートして重複を削除
my %cnt;
@asin = sort {$a <=> $b} @asin;
@asin = grep {!$cnt{$_}++} @asin;
# 出力
$" = "\n";
print "@asin", "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment