#!/usr/bin/perl -w # interleave.pl - Don Yang (uguu.org) # # Take input strings (one per line) and mix them on to the same line. # # 12/23/11 use strict; my @lines = <>; my $length = 0; foreach (@lines) { chomp; if( $length < length $_ ) { $length = length $_; } } for(my $i = 0; $i < $length; $i++) { for(my $j = 0; $j <= $#lines; $j++) { if( $i < length $lines[$j] ) { print substr($lines[$j], $i, 1); } else { print " "; } } } print "\n";