in reply to My first post!

I don't know whether you always use the @a[0] style syntax for retrieving an array value but that won't pass warnings. When you retreive a scalar you change the '@' sigil to a '$' so it reads $a[0]. Also, an alternative would be assign $" = '' and just fetch list slices. I bring this up only because it is poor perl style and I'd hate for you to carry that over into your real code. Also, you wouldn't normally have four print statements. Either concatenate that into a single string or leave it as a list.

print "@a[0 .. 3] ", "@b[0, 1, 4, 2, 3]", "@c[3, 4, 0, 1, 4, 0] ", "@b[3, 0, 2, 3, 3, 4]\n";

The preceding is further reduced to the simple and beautiful:

@a = split //, "justin"; @b = split //, "anthony"; @c = split //, "peter"; @d = split //, "lucky"; $" = ''; $\ = "\n"; $, = " "; print "@a[0 .. 3]", "@b[0, 1, 4, 2, 3]@c[3, 4]", "@c[0, 1, 4]$d[0]", "@b[3, 0]@d[2, 3]@c[3, 4]";

Replies are listed 'Best First'.
Re: Re: My first post!
by monsieur_champs (Curate) on May 28, 2003 at 22:11 UTC

    Dear diotalevi

    I also love reading Umberto Eco's books.

    Your nick is a nice mispell. I never could choose a better one.

    With all respect that your post deserves, I think that you forgot the purpose of this section: "Obfuscation" means that things here must look weird, at least ;-]

    I'm quite sure you're a lot better than me on make things look strange, but here is my two cents:

    lets change

    @a = split //, "justin"; @b = split //, "anthony"; @c = split //, "peter"; @d = split //, "lucky"; $" = ''; $\ = "\n"; $, = " ";

    for the more compact

    ($a,$",$\,$,)=('a','',"\n",' '); map{@{$a++}=split//}qw|justin anthony peter lucky|;

    What will lead us to (I shortened this a little):

    ($a,$",$\,$,)=('a','',"\n",' '); map{@{$a++}=split//}qw|justin anthony peter lucky|; print join$",@{($a='a')++}[0..3],$,,@{$a++}[0,1,4, ,2,3],@{$a}[3,4],$,,@{$a++}[0,1,4],${$a}[0], $,,@{($a='b')++}[3,0],@{++$a}[2,3],++$a,'r';

    That is beautifull, even not looking as didatic as you made it the first time. Maybe someone else could golf it down to a line or two (please?).

    BTW, nice post, Mr. .:G0BLiN:.. I spent a nice time hacking trough your code. Thank you for that.

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Luis Campos de Carvalho
    Just Another Perl Programmer
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    

      Ah, well that. Yes. I brought in the perl grammar rule book because it just looked like the author was writing the code with insufficient knowledge. The code is otherwise fine, the style needed improvement if it were to be used for non-obfuscatory porpoises.