blob: ec6ff9b1a3d2e898eb80e1113c9cbf59b591ec5a (
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
70
71
72
|
#!/usr/bin/perl
# ponysaylist
# Prints a list of ponies in columns
#
# Licensed under WTFPL
# See COPYING for details
# Author: Mattias Andrée, maandree@kth.se
%hash = ();
$argc = @ARGV;
$i = 0;
while ($i < $argc)
{
$source = $ARGV[$i];
$i += 1;
$target = $ARGV[$i];
$i += 1;
if ($source eq $target)
{
$hash{$source} = [ () ];
}
}
$i = 0;
while ($i < $argc)
{
$source = $ARGV[$i];
$i += 1;
$target = $ARGV[$i];
$i += 1;
unless ($source eq $target)
{
push @{ $hash{$target} }, $source;
}
}
$i = 0;
while ($i < $argc)
{
$source = $ARGV[$i];
$i += 1;
$target = $ARGV[$i];
$i += 1;
if ($source eq $target)
{
@list = @{ $hash{$source} };
$first = 1;
print $source;
foreach $link (@list)
{
if ($first eq 1)
{
print " (".$link;
$first = 0;
}
else
{
print " ".$link;
}
}
if ($first eq 0)
{
print ")";
}
print "\n";
}
}
|