#!/usr/bin/perl 

use strict;
use warnings;

print q{ <?php 
    require_once('admin.php');
    global $utw;
};

while (<>) {
  eval {
    /^id=(\d+) / or die "no id: $_";
    my $id = $1;

    my @tags = ();
    while (/\bt=(\S+)\b/g) {
      push @tags, $1;
    }

    if (scalar @tags < 1) {
      die "no tags: $_";
    }

    print q{$utw->SaveTags(}.$id.q{, array("}.join(q{","}, @tags).q{"));
};
  };

  if ($@) { warn $@; }
}
# id=1000 t=spam t=hashcash t=networks t=spamassassin t=taughannock t=couple t=overview t=room t=site t=state 

print q{
    ?>
};

