i'm probably doing well known things here, but comments are appriciated: sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift @a,$a;}sub b{$c.=reverse shift;while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);shift@b;}}$a="ifpubotukv";$d="lfbdmifssq";@b=split(//,'74741');$a='s.'.$d.$a;while($a ne ""){b(substr($a,0,2));$a=substr($a,2);}print join(" ",@a);

Replies are listed 'Best First'.
Re: My First JAPH - Be Gentle :-)
by clintp (Curate) on Mar 19, 2001 at 21:43 UTC
    Only a couple of style notes. while($a ne "") is better written (in this case) as while($a).

    The print join(" ", @a) is almost always (as least where you're being obscure) better written as print "@a".

    Improvements?

    This was a pretty good first attempt. I'll only make two suggestions.

    The code in the while loop b(substr($a,0,2);$a=substr($a,2); can be tightened up a bit with b $a=~/(.{2})/;$a=$'. (Hope that pasted right). The same formula can be used in b(). Since b() isn't returning a value at all, adding a shift to the very end of it, and then in the while loop saying:

    while($a) { $a=b $a=~/(.{2})(.*)/g; }

    Tightens things up nicely.

    This further shortens up to:

    1 while($a=b $a=~/(.{2})(.*)/g);
      This seems to be a reply about my code but is attached to code be TStanley - is there some trickery involved with finding comments relating to a post?

      Anyway, thanks for the tips!