On 15/11/2007, Jasper <[EMAIL PROTECTED]> wrote: > > \$h{$_='()'x$ARGV[0]}; > \$h{$_,reverse}while s/\)(.*?)\(/$1()/; > print for sort keys %h;
Phil points out that reverse isn't actually a mirror (and scalar reverse makes this horribly incorrect), so it turns out I have to do this in two passes. \$h{$_='()'x $ARGV[0]}; \$h{$_}while s/\)(.*?)\(/$1()/; $_='()'x pop; \$h{$_}while s/(.*)\)(.*?)\(/$1()$2/; print for sort keys %h; Hopefully someone can fix that :D -- Jasper