Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: outputting fun

by Corion (Pope)
on Aug 29, 2000 at 19:47 UTC ( #30154=note: print w/ replies, xml ) Need Help??


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) :-)


Comment on Re: outputting fun
Download Code
RE: Re: outputting fun
by lindex (Friar) on Aug 30, 2000 at 11:55 UTC
    Just would like to say that Iam a wingnut :)
    for(my($c)=71,my($i)=0; $c >= 65; $c--,$i++) { print ( (chr(65)..chr($c)), (' 'x($i+($i-1))), reverse(chr(65)..chr(($c==71)? $c-1 : $c)), "\n" ); }
    p.s. I broke it into multi-line so that it was readable :)



    lindex
    /****************************/ jason@gost.net, wh@ckz.org http://jason.gost.net /*****************************/
Re: Re: outputting fun
by stefp (Vicar) on Mar 28, 2001 at 00:10 UTC
    There is the obvious
    print <<EOF; ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A EOF
    How about?
    $a = "ABCDEFGFEDCBA\n"; print($a), substr($a, 7-$_, 2*$_-1) = " " ." " x ($_-1) for 1..7
    -- stef

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://30154]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-11-01 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (228 votes), past polls