1
0
Fork 0
mirror of https://github.com/erkin/ponysay.git synced 2025-02-28 22:44:33 +01:00

Simplification of ponysaylinklist.pl as well.

This commit is contained in:
spider-mario 2012-07-24 16:57:21 +02:00
parent a30723e36d
commit 0923d3c727

View file

@ -9,63 +9,27 @@
# Author: Mattias Andrée, maandree@kth.se # Author: Mattias Andrée, maandree@kth.se
%hash = (); use strict;
$argc = @ARGV; use warnings;
use utf8;
use List::MoreUtils qw(natatime);
$i = 0; my %hash;
while ($i < $argc) my $argc = @ARGV;
{
$source = $ARGV[$i]; my $it = natatime 2, @ARGV;
$i += 1; while (my ($source, $target) = &$it) {
$target = $ARGV[$i]; unless ($source eq $target) {
$i += 1; push @{$hash{$target}}, $source;
if ($source eq $target)
{
$hash{$source} = [ () ];
} }
} }
$i = 0; $it = natatime 2, @ARGV;
while ($i < $argc) while (my ($source, $target) = &$it) {
{ if ($source eq $target) {
$source = $ARGV[$i]; my @list = @{$hash{$source} // []};
$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; print $source;
foreach $link (@list) print ' (', join(' ', @list), ')' if @list;
{
if ($first eq 1)
{
print " (".$link;
$first = 0;
}
else
{
print " ".$link;
}
}
if ($first eq 0)
{
print ")";
}
print "\n"; print "\n";
} }
} }