blob: a3f29e3aece954c450548589311fc7e867afc9e0 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/usr/bin/perl -T -w
# This is used to reverse xlock format back to life
&search;
sub search {
local ($row, $col, $NOTUSED, $x, $y);
local (@array);
$HALFMAX = 64; # really 32 but being safe
$MAXCOL = $MINCOL = $MAXROW = $MINROW = $HALFMAX;
$NOTUSED = -127;
$row = $col = $NOTUSED;
$number = 0;
while (<>) {
if (!($_ =~ /^#/)) {
@chars = split(//);
$number = 0;
$col = $NOTUSED;
$negative = 1;
foreach $c (@chars) {
if ($c =~ /[-]/) {
$negative = -1;
} elsif ($c =~ /[0123456789]/) {
$number = $number * 10 + ($c - '0');
} elsif ($c =~ /[,]/) { # Last number does not have a ","
if ($col > $NOTUSED) {
$row = $number * $negative;
$col = $col + $HALFMAX;
$row = $row + $HALFMAX;
$array{$col, $row} = 1;
if ($col > $MAXCOL) {
$MAXCOL = $col;
} elsif ($col < $MINCOL) {
$MINCOL = $col;
}
if ($row > $MAXROW) {
$MAXROW = $row;
} elsif ($row < $MINROW) {
$MINROW = $row;
}
$col = $NOTUSED;
} else {
$col = $number * $negative;
}
$number = 0;
$negative = 1;
} elsif ($c =~ /[{}\/]/) { # Last number does not have a ","
$col = $NOTUSED;
$number = 0;
$negative = 1;
}
}
}
}
$x=$MAXCOL - $MINCOL + 1;
$y=$MAXROW - $MINROW + 1;
print "#x=$x, y=$y\n";
for ($j = $MINROW; $j <= $MAXROW; $j++) {
for ($i = $MINCOL; $i <= $MAXCOL; $i++) {
if ($array{$i, $j}) {
print "*";
} else {
print ".";
}
}
print "\n";
}
}
|