mirror of
https://github.com/erkin/ponysay
synced 2024-11-13 23:27:14 +00:00
Simplification of ponysaylinklist.pl as well.
This commit is contained in:
parent
a30723e36d
commit
0923d3c727
1 changed files with 20 additions and 56 deletions
|
@ -9,64 +9,28 @@
|
|||
# Author: Mattias Andrée, maandree@kth.se
|
||||
|
||||
|
||||
%hash = ();
|
||||
$argc = @ARGV;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use List::MoreUtils qw(natatime);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $argc)
|
||||
{
|
||||
$source = $ARGV[$i];
|
||||
$i += 1;
|
||||
$target = $ARGV[$i];
|
||||
$i += 1;
|
||||
if ($source eq $target)
|
||||
{
|
||||
$hash{$source} = [ () ];
|
||||
}
|
||||
my %hash;
|
||||
my $argc = @ARGV;
|
||||
|
||||
my $it = natatime 2, @ARGV;
|
||||
while (my ($source, $target) = &$it) {
|
||||
unless ($source eq $target) {
|
||||
push @{$hash{$target}}, $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";
|
||||
}
|
||||
$it = natatime 2, @ARGV;
|
||||
while (my ($source, $target) = &$it) {
|
||||
if ($source eq $target) {
|
||||
my @list = @{$hash{$source} // []};
|
||||
print $source;
|
||||
print ' (', join(' ', @list), ')' if @list;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue