Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!jarthur!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: shortest self-reproducing Perl program Message-ID: <7490@jpl-devvax.JPL.NASA.GOV> Date: 20 Mar 90 23:47:29 GMT References: <1990Mar20.203516.8429@iwarp.intel.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 44 In article <1990Mar20.203516.8429@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: : Okay, here's my entry for the shortest self-reproducing Perl program. : Any takers for shorter? Any one liners? : : print<<'E'x 2,"E\n"; : print<<'E'x 2,"E\n"; : E : : The program must be fed to an unadorned Perl command 'perl' and : produce the output that would make 'perl' look like it has been : replaced with 'cat'. The null program is not a valid submission. (I : claim it first... :-) An obvious abridgement is to delete all the E's: print<<''x 2,"\n"; print<<''x 2,"\n"; Note the blank line at the end. A not-so-obvious improvement is that the last semicolon is now optional. (For shame! You of all people should have thought of this one, Randal!) print<<''x 2,"\n" print<<''x 2,"\n" It's too bad you said the thing about cat. Otherwise die<<''x 2."\n" die<<''x 2."\n" would qualifiy. But, we can shorten the "\n" by two characters: print<<''x 2,$/ print<<''x 2,$/ I haven't thought about one liners yet. Larry