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.
This is obviously not the smallest possible code, but a bit more Perlish and elegant (IMholyO) :-)#!/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"); };
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Re: outputting fun
by lindex (Friar) on Aug 30, 2000 at 11:55 UTC | |
Re: Re: outputting fun
by stefp (Vicar) on Mar 28, 2001 at 00:10 UTC |
In Section
Seekers of Perl Wisdom