File: bot-basicbot-pluggable-infobot-upgrade

package info (click to toggle)
libbot-basicbot-pluggable-perl 1.30%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: perl: 3,153; makefile: 17
file content (32 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
use warnings;
use strict;
use Storable qw(retrieve nstore);
use File::Copy qw( cp );

unless (-e "Infobot.storable") {
  die "I can't see Infobot.storable in ./\n";
}

if (-e "Infobot.storable.backup") {
  die "There's already a backup of Infobot.storable in ./\n";
}

cp("Infobot.storable", "Infobot.storable.backup")
  or die "Can't back up Infobot.storable: $!\n";

unless (-s "Infobot.storable" == -s "Infobot.storable.backup") {
  die "Infobot.storable backup isn't the same size!\n"
}

my $data = retrieve("Infobot.storable")
  or die "Can't load Infobot.storable for some reason\n";

my $new;
warn "converting...\n";
for my $factoid (keys %{  $data->{infobot}  }) {
  $new->{ "infobot_$factoid" } = delete $data->{infobot}{$factoid};
}

nstore($new, "Infobot.storable");
warn "Saved new Infobot.storable\n";