http://qs1969.pair.com?node_id=30154


in reply to outputting fun

Here's my try at it. It uses two forms of string replacement - one transliteration, replacing every G with a space, and one regular expression, replacing a single character, followed by one or more spaces and then that character again, with two more spaces.

#!/usr/bin/perl -w use strict; my $line; print( $line = join( "", ('A' .. 'G'), reverse ( 'A'..'F' )), "\n" ); $line =~ tr/G/ /; print( $line, "\n" ); while ($line !~ /^\s+$/) { $line =~ s/(\S)(\s+)\1/ $2 /; print( $line, "\n"); };
This is obviously not the smallest possible code, but a bit more Perlish and elegant (IMholyO) :-)