Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jato!lwall From: lwall@jato.Jpl.Nasa.Gov (Larry Wall) Newsgroups: alt.hackers Subject: Re: Puzzle Message-ID: <2740@jato.Jpl.Nasa.Gov> Date: 2 Feb 90 21:31:20 GMT References: <13960@reed.UUCP> Reply-To: lwall@jato.Jpl.Nasa.Gov (Larry Wall) Distribution: usa Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 36 Approved: by me, myself & eye In article <13960@reed.UUCP> justin@reed.UUCP (the breakdown voltage) writes: : Ok, hackers, let's see just how good you REALLY are: : : What does the following shell/sed script do (hint: it was called rlrbw :-)? : You could run it, but that'd be too easy. : : #!/bin/sh : string='' : if test -n "$1" : then : value=$1 : while test $value -gt 1 : do : value=`expr $value - 1` : string=${string}0 : done : fi : sed 'x : s/.*/'$string'/ : x : : begin : s/\(.*\)[ ]\([^ ][^ ]*\)[ ]*/\2 \1/ : t fake : : fake : x : s/0/1/ : x : t begin' At a guess, I'd say it does something like: #!/usr/bin/perl while(){split;for(1..$ARGV[0]){unshift(@_,pop(@_));}print"@_\n";} Larry Wall lwall@jpl-devvax.jpl.nasa.gov