Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!psuvax1!news From: flee@cs.psu.edu (Felix Lee) Newsgroups: comp.lang.perl Subject: Wordless Perl. Message-ID: Date: 4 Feb 91 19:20:24 GMT References: <1991Feb4.163023.2980@uvaarpa.Virginia.EDU> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 33 Nntp-Posting-Host: dictionopolis.cs.psu.edu 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