in reply to Re: Worst thing you ever made with Perl
in thread Worst thing you ever made with Perl

Putting whitespace in variable names (as, $foo {bar}) is something I would do in an obfuscation, to make the code *less* clear.

I don't see any whitespace in a variable name. I see whitespace between a variable name and an 'operator' though. Putting whitespace between '$foo' and '{bar}' is what I do all the time. It serves exactly the same purpose as putting whitespace around the addition operator, and between words in a sentence. Becauselongblobsoftextwithoutspacesinbetweenishardertoread.

Abigail

  • Comment on Re: Worst thing you ever made with Perl

Replies are listed 'Best First'.
Re: Worst thing you ever made with Perl
by jonadab (Parson) on Oct 01, 2003 at 17:02 UTC

    This was in the context of interpolation. Operators aren't interpolated, generally speaking. (Yeah, I know, methods are interpolated in Perl6... Perl6 is different in a number of ways (some of which I look forward to, but I digress).) In Perl5, $foo{bar} is a scalar value -- hence, the scalar sigil. If you were referring to the hash value foo, it would be spelled %foo, and then anything that followed would be an operator. (Again, I know a lot of this changes in Perl6... but there are other corresponding changes surrounding it that give a consistency Perl5 wouldn't have if $foo were to refer to %foo in the way you seem to imply.) As it stands, $foo{bar} is a single scalar value. That's my story and I'm sticking to it.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      I've never disputed that '$foo {bar}' is a single scalar value. But so are '$_ x 5' and '-M $0'. Just the fact that expressions result in single scalar values, doesn't mean one can't sprinkle whitespace between tokens to make things more readable.

      Abigail