[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Sideways Perl



On Mon, 11 Oct 1999, Zak McGregor wrote:
>On Oct 11, Ronald J Kimball explained earnestly:
>> On Mon, Oct 11, 1999 at 09:54:33PM +0200, Zak McGregor wrote:
>
>> >   for (@l = map {chomp; $m = length if $m < length; $_} <>) {
>> >     print undef substr($_.= " "x$m,$m)
>> >   } print join "\n", reverse map {join "", map chop, @l} 1..$m 
>> > 
>> 
>> Why do you print undef?
>
>Ooops - I was trying to decipher the mysteries in the code, and just
>didn't remove it.

Actually, the code is not meant to be very mysterious. The
idea is pretty simple. for(@l = ...) sets $m to the maximum
width of the input. Then undef(substr(...)) pads every string
to the maximum width. Now that there is a "rectangle" in @l,
every invocation of join("", map chop, @l) removes a "column"
from the right (and turns it on its side).

--
Tushar Samant
~
~
:wq


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe