[comp.lang.perl] Wordless Perl.

flee@cs.psu.edu (Felix Lee) (02/05/91)

Dale Worley wonders:
> Is there a non-trivial Perl program that consists entirely of
> punctuation marks?

Well, I can't think of a way to write a loop with only punctuation.
Worse, I can't find a way of generating output.  This is Perl's fatal
flaw: it requires you to use alphabetic characters.  True terseness
lies in hieroglyphic programming languages.

But if you'll allow the "-p" flag, here's "uniq":
	#!/usr/bin/perl -p
	$: = $_;
	/^$__$/ && ($_ = '');
	$__ = $:;

If you'll allow preprocessed input, here's a (very slow) spell checker.
	#!/usr/bin/perl -p
	/^-$/
	 ? (++$[, $_='')
	 : $[
	   ? (/^$/ || $_{$_}) && ($_ = '')
	   : ($_{$_}++, $_ = '');
Name it "spckrm" and use the following script:
	#!/bin/sh
	(cat /usr/dict/words
	 echo '-'
	 perl -pe 'tr/A-Z/a-z/;$_=join("\n",split(/[^a-z]+/))."\n"' ${1+"$@"}
	) | spckrm | sort -u

This is only scratching the surface of wordless Perl.  More complex
things are surely possible.
--
Felix Lee	flee@cs.psu.edu

brister@decwrl.dec.com (James Brister) (02/06/91)

On 4 Feb 91 19:20:24 GMT, flee@cs.psu.edu (Felix Lee) said:

[ three Perl programs that consist entirely of punctuation marks ]

It seems to me time for an Obfuscated Perl competition....

James
--
James Brister                                           brister@decwrl.dec.com
DEC Western Software Lab., Palo Alto, CA    {uunet,sun,pyramid}!decwrl!brister

chip@tct.uucp (Chip Salzenberg) (02/07/91)

According to brister@decwrl.dec.com (James Brister):
>It seems to me time for an Obfuscated Perl competition....

"Obfuscated Perl" is redundant.  (But I love it anyway.)
-- 
Chip Salzenberg at Teltronics/TCT     <chip@tct.uucp>, <uunet!pdn!tct!chip>
 "Most of my code is written by myself.  That is why so little gets done."
                 -- Herman "HLLs will never fly" Rubin

bob@MorningStar.Com (Bob Sutterfield) (02/07/91)

TECO used to be the language I used as an example of what modem line
noise looks like, then Sendmail.  Now it's perl.  That's progress, I
guess.