http://qs321.pair.com?node_id=75205


in reply to Re: Triangle Golf
in thread Triangle Golf

The above didn't work for me. $\ is undefined by default so the newline doesn't print and $= is 60 by default so the tests fail. This is the best fix I could come up with, unfortunately with one extra character:

@ARGV='ctriangle.txt';sub n{print " "x(40-$r/2)."$x\n"};$/=$w;$_=<>; ($r=length($x.=" $_"))>$/and $/=$r,n,$x=''for split;n;

Replies are listed 'Best First'.
Re: Re: Re: Triangle Golf
by japhy (Canon) on Apr 24, 2001 at 23:05 UTC
    I'm sorry. I posted the code without testing it. I had meant $/ instead of $\, but I see that wouldn't have worked. Sorry about that.

    japhy -- Perl and Regex Hacker