#!/usr/bin/perl
# Myst Shen, Jan.31, 2009. Last modified on Feb. 10, 2009.
use warnings;
use strict;
my ($x,$y,$y2,%h,@data,@rec,@rec2);
foreach (<>) {
push (@data, split);
$x ++;
}
$x < (`tput cols`) || die "Please widen this terminal.\n";
%h = @data;
$y=1;
foreach my $k (sort keys %h) {
$y2=1;
foreach my $k2 (sort keys %h) {
if ($k && $k2 && $h{$k} eq $h{$k2} && $k ne $k2) {
push (@rec, "$k $h{$k} $y\n");
push (@rec, "$k2 $h{$k2} $y2\n");
}
$y2++;
}
$y++;
}
@rec2 = @rec;
L: foreach my $i (@rec2) {
shift @rec;
foreach my $j (@rec) {
next L if ($i eq $j)
}
push (@rec, $i);
}
print "@rec\n";
while (@rec) {
my @rec2=@rec;
shift @rec;
my @a = split (/ |\n/, $rec[0]);
my @b = split (/ |\n/, $rec2[0]);
my $pr = " " x $a[2];
my $pr2 = "'" x ($b[2]-$a[2]+1);
print "$pr$pr2\n";
shift @rec;
}
|