in reply to Strange finish!!

I think most people would agree that omitting the semi-colon at the end of a block causes grief. Just because you can does not mean you should. For example:
if ($x == 42) { print "I have the answer\n" }
Then later add a line:
if ($x == 42) { print "I have the answer\n" print "to Life, the Universe, and Everything\n"; }
and it fails with a syntax error. Doh!

Replies are listed 'Best First'.
Re^2: Strange finish!!
by codeacrobat (Chaplain) on Nov 07, 2007 at 11:53 UTC
    One should also make it a habit to leave a comma in hash definitions.
    %fortytwo = ( "I have" => "the answer\n", );
    You don't have to take care of fixing the previous line, when adding a new one.
    %fortytwo = ( "I have" => "the answer\n", "to" => "Life, the Universe, and Everything\n", );

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
      One should also make it a habit to leave a comma in hash definitions...
      And then you get bitten by exactly that habit when dealing with JavaScript:
      var foo = {a:'A', b:'B',}; //syntax error


      holli, /regexed monk/
        Not just javascript, but C and Java as well. In fact, Perl is the first language I've seen that allows (and actually encourages) trailing commas like that. I have to admit, it's really handy. I hate editing big SQL statements and moving things around because I inevitably have a select A,B,C, from FOO; give me an error. Perl gives us the luxury of making the statements easy to move around or append to. Nice feature that.
        --
        I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.