#!/usr/bin/perl -w # # Run a command on all lexically-ordered pairs of filenames in the # list given. That is, ('a', 'b') is a pair but ('b', 'a') won't be # run because 'a' comes before 'b' alphabetically. # # Part of similarity-utils version 0.1. # use strict; die "usage: $0 prog files...\nfor 'prog', try 'similarity' or 'similarity_by_diff'\n" if @ARGV < 3; my $prog = shift @ARGV; my @files = grep { -f or warn("skipping non-file $_\n"), 0 } @ARGV; I: foreach my $i (@files) { J: foreach my $j (@files) { next unless $i lt $j; system($prog, $i, $j) && die "running $prog $i $j failed: $!"; } }