> -----Original Message----- > From: Neko [mailto:tgy@chocobo.org] > Sent: Monday, April 24, 2000 4:27 AM > To: Ronald J Kimball > Cc: Arjen Wiersma; fwp@technofile.org > Subject: Re: [FWP] string increment > > > On Sun, 23 Apr 2000, Ronald J Kimball wrote: > > > On Mon, Apr 24, 2000 at 05:39:36AM +0200, Arjen Wiersma wrote: > > > > > > > > perl -e '@a=qw(a a a a); for($i=$#a;-1 < $i; $i--) { > > > > > for($x=0;$x<25;$x++) {$b = ord($a[$i]); $a[$i] = > chr(++$b); print > > > > > @a; print "\n"; } }' > > This fails to print 'aaaa'. > > > How about: > > > > perl -le '$_ = "aaaa"; for ($i=length($_)-1; $i>=0; --$i) { > > for $c ("a".."z") { substr($_,$i,1) = $c; print } }' > > This will print 'aaaz' twice. Shortening the range to > "b".."z" and adding > a print() to the beginning: > > perl -le 'print $_ = "aaaa"; for ($i=length($_)-1; $i>=0; --$i) { > for $c ("b".."z") { substr($_,$i,1) = $c; print } }' > > Not faster like Arjen wanted, but down to 84 chars: > > perl -le'print$_="aaaa";$i=-1+length;print > while++substr($_,$i,1)lt"z"or$i--;print' > > That's 4 over par. I bet someone can do better. Golf anyone? :) well, I'm new to the list, so I'm still getting used to the rules, but how about: perl -le'$_="a"x4;$i=-1+length;do{print}while++substr($_,$i,1)lt"z"or$i--;print' that's a bogey :) --Geoff > > -- > Neko > > > > ==== Want to unsubscribe from Fun With Perl? Well, if you insist... > ==== Send email to <fwp-request@technofile.org> with message _body_ > ==== unsubscribe > ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe