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

RE: [FWP] Recursion, anyone?



>From fwp-l Wed Apr 11 14:08:10 2001

On Wed 11 Apr, Kort, Eric wrote:
>
> > In another direction, I wrote one that prints all words of
> > 1-3 characters
> > made only by lowercase letters. It goes like:
> >
> >     perl -le'$x="a";while(length$x<4){print$x++}'
> >
> > For longer words, change 4 to (whatever the maximum length of
> > words)+1.
> > This code uses a magic behaviour of the ++ operation. See perlop on
> > ++ if you can't understand this.
>
> I applaud you.
>
> Fortunately, I am saved from my never posting promise because your one
> liner, while lovely and impressive, only prints alpha's, not whatever you
> want to put in the element set as mine does.  I am sure your example
> illustrates some optimizations I could incorporate, which I will now think
> about <sound of mind switching to 'ON'>.
>

URLs are not case sensitive so you only need a-z, 0-9 and "-".

Here is a 1 liner at 81 chars :-(,  you can still post

perl -le'sub x{print@_;if(length$_[0]<$ARGV[0]){x($_[0].$_)
for(a..z,0..9,"-")}}x'

Richard

-- 

Richard@waveney.org

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