Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: Worst thing you ever made with Perl

by jonadab (Parson)
on Sep 30, 2003 at 22:33 UTC ( [id://295465]=note: print w/replies, xml ) Need Help??


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

print 3 . 5; # 35 print 3.5; # 3.5

Warnings will catch that for you.

%foo = (bar => "xyzzy") print "-$foo{bar}-"; # -xyzzy- print "-$foo {bar}-"; # - {bar}-

Putting a space in the middle of a variable is just a wee bit different from indenting lines within a function.

$a = 1; print $a - -5; # 6 print $a -- 5; # error print q qhelloq; # hello print qqhelloq; # qqhelloq

All of these examples are highly contrived, and not at all the same as wanting to indent lines to properly reflect a nested structure and being told that no, those lines should not be indented, because the leading whitespace is significant. And as for having blank lines be significant... the English language lacks the words to describe my view of that. At this point I'm thinking I'll probably continue to use comments as I have been doing, after all. The prospect of being able to automatically generate documentation from the POD comments embedded in the code was attractive to me in principle, but apparently it's not flexible enough to be used at all the way I want.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Replies are listed 'Best First'.
Re: Re: Re: Re: Worst thing you ever made with Perl
by Juerd (Abbot) on Oct 01, 2003 at 07:50 UTC

    Putting a space in the middle of a variable is just a wee bit different from indenting lines within a function.

    Is it?

    %foo = (bar => "xyzzy") print $foo{bar}; # xyzzy print $foo {bar}; # xyzzy (!!!) print "-$foo{bar}-"; # -xyzzy- print "-$foo {bar}-"; # - {bar}-

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Putting a space in the middle of a variable is just a wee bit different from indenting lines within a function.
      Is it?

      Yes, absolutely, without qualification, it is fundamentally different. Indenting everything within a block is a strongly-recommended best practice in good coding style, because it greatly enhances clarity. Being told that I shouldn't do that with POD is as far as I'm concerned a good enough reason in itself not to use POD (within blocks -- which is where I wanted to put the information in question), because I would have to adopt an unclear coding style in order to do so. Now I understand why people who use POD stick it all in big huge chunks, rather than interspersing it through the code like comments -- because fundamentally it's not designed to be interspersed the way comments can be. (I had been led to believe otherwise.)

      Putting whitespace in variable names (as, $foo {bar}) is something I would do in an obfuscation, to make the code *less* clear. If it alters the meaning, so what? It isn't something I'd normally expect good code to ever do, so at worst it's a very minor gotcha.


      $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
        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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://295465]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found