develooper Front page | perl.golf | Postings from August 2002

Re: this must be golfable

Thread Previous | Thread Next
From:
Prakash Kailasa
Date:
August 12, 2002 08:51
Subject:
Re: this must be golfable
Message ID:
20020812154834.GC2479@seisint.com
    -p $_=y/|.//d&&pack(B8,$_)		# phil
    -p $_=pack B8 x!!y/|.//d,$_		# eugene
    -p $_=y/|.//d?pack B8,$_:""		# mtve

Assuming the same rule as others (ignore the top and bottom lines)

    -p y/|.//d,$_=pack B8,$_		# pk

/prakash

On Sun, Aug 11, 2002 at 03:55:39PM +0200, Eugene van der Pijll wrote:
> En op 11 augustus 2002 sprak Phil Carmody:
> > I'd just realised 
> >     perl -pe '$_=y/o |./10/d&&pack(B8,$_)'
> > works.
> 
> Not if the top and bottom lines are present in your input:
> 
> $ cat ascii 
> ___________
> | o   .  o|
> | o o . oo|
> | o   . oo|
> | o  o.  o|
> | o  o.  o|
> |    o. o |
> ___________
> $ perl -pe '$_=y/|.//d&&pack(B8,$_)' ascii 
> 0ASCII
> 0$
> 
> > --- Eugene van der Pijll <E.C.vanderPijll@phys.uu.nl> wrote:
> > >   perl -pe '$_=y/|.//d?pack(B8,$_):""'
> > >   perl -ne 'y/|.//d&&print pack B8,$_'
> 
>       perl -pe '$_=pack y/|.//d?B8:"",$_'
>       perl -pe '$_=pack B8 x!!y/|.//d,$_'
> 
> (-ugene
> 

-- 
|Be careful when a loop exits to the same place from side and bottom.  |

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About