3 # $ANH-Date$ $ANH-Branch$:$ANH-Revision$
10 # TODO: switch to Getopt::Long so we can parse normal arguments too
11 $Getopt::Std
::STANDARD_HELP_VERSION
= TRUE
;
15 'd' => 'debug mode; parse objects.txt to stdout instead of updating',
18 getopts
(join('', keys(%commands)));
20 my $debug = (defined($opt_d) && $opt_d == 1);
22 my $outfile = $debug ?
"-" : "objects.txt";
23 my $infile = $debug ?
"objects.txt" : "objects.bak";
27 if (-e
"$infile") { die "something didn't clean up objects.bak from last time; stopping\n"; }
28 rename($outfile,$infile) or die "couldn't move objects.txt to objects.bak; stopping\n";
31 open(INFILE
, "<$infile") or bail
("couldn't open $infile; bailing");
32 open(OUTFILE
, ">$outfile") or bail
("couldn't open $outfile; bailing");
34 while (my $line = <INFILE
>)
36 if (my ($tiletext) = $line =~ /^# tile \d+ (.*)/)
38 $line = "# tile $tilecount $tiletext\n";
48 unless ($debug) { unlink $infile; }
52 sub main
::HELP_MESSAGE
()
55 Usage: renumtiles.pl [OPTIONS] <textfile>
58 foreach $cmd (keys(%commands)) {
59 printf("%10s %s\n", '-'.$cmd, $commands{$cmd});
63 \t--help display this help message and exit
64 \t--version display version and exit
69 sub main
::VERSION_MESSAGE
()
71 my ($objglob, $optpackage, $ver, $switches) = @_;
73 renumtiles $ver -- tile-renumbering utility for aNetHack
81 rename ($infile,$outfile);