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

Re: [FWP] Would you like to buy a vowel?



On Fri, Mar 23, 2001 at 02:53:19PM -0500, yanick1@sympatico.ca wrote:
> On Fri, Mar 23, 2001 at 07:58:55PM +0200, Ilmari Karonen wrote:
> > Okay, can anyone here shorten this JAPH?  Par is 113.  There's a trivial
> > 7 stroke saving if you omit the final newline, but I'd rather keep it.
> > 
> > $|=@_=$_="\rJust another Perl hacker,\n";chop;s/${\(a..z)[rand 26]}/#/ig&&(@_=($_,@_))while/\w/;sleep print for@_
> 
> 	112, but using a slightly different approach (and with the
> chance to print a first line with a letter revealed):
> 
> $|++;$_="\rJust another Perl hacker,";s/\w/$&\b#/g;
> s/(${\(a..z)[rand+26]}).#/$1/ig&&sleep print while/#/;die"\n";

That's 113 with the trailing ;. ;-)

Here's a 106 char version:

  $|=s""\rJust another Perl hacker,";s/\w/$&\b#/g;
  s/(${\chr(97+rand$=)}).#/$1/ig&&sleep print while/#/;die$/

And for a slightly different effect, you could leave off the /g of
the second substitution and save another character.

You could also replace \b with a real backspace, and \r with a real
carriage return, and save another two chars.

Too bad there are regex special chars between 'Z' and 'a', or else
I could have omitted another char:

  $|=s""\rJust another Perl hacker,";s/\w/$&\b#/g;
  s/(${\chr(65+rand$=)}).#/$1/g&&sleep print while/#/;die$/

will work *some*times.


Abigail

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