eval '(exit $?0)' && eval 'exec perl -wS $0 ${1+"$@"}'
    && eval 'exec perl -wS $0 $argv:q'
    if $running_under_some_shell;
$running_under_some_shell = 0;
#!/usr/bin/perl

########################################################################
# Author:  I. Dan Melamed
# Computes:	interleaves the lines of several files
# Streams:	all the files
# N.B.:		if files are different length, results are unpredictable
#######################################################################

$| = 1;

#check for correct usage
if ($#ARGV < 0) {
    print "usage: $0 <file1> [<file2> ...] \n";
    exit; 
};

while (@ARGV) {
    $counter++;
    $handlename = "H".$counter;
    open($handlename, $ARGV[0]) || die "Couldn't open $ARGV[0]: $!\n";
    push(@fileptr, \*$handlename);
    shift;
};
while (1) {
print "**************************************************\n";
$stevec = 0;
    for($i = 0; $i < @fileptr; $i++) {
	$stevec++;
	$handle = $fileptr[$i];
	$line = <$handle>;
	if (not defined $line) {
	    exit;
	};
	print $line;
	print $stevec;
	print "------\n";
    };
};
