in reply to Re^2: Strange finish!!
in thread Strange finish!!

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/

Replies are listed 'Best First'.
Re^4: Strange finish!!
by KurtSchwind (Chaplain) on Nov 07, 2007 at 15:45 UTC
    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.
      This is solvable with formatting. I always format SQL like this:
      SELECT A , B , C FROM FOO, BAR WHERE foo.barid = bar.barid AND foo.something = 'special value'
      and then adding/removing fields from the SQL statement is far less likely to give me errors.
      It's also very useful when generating Perl code via a program. You don't need to worry about omitting the final comma, which the generation code.
      I chose the Javascript analogy because the Javascipt Object Notation is pretty similar to Perl datastructure syntax. (Basically replace => by : and you're done). From what I know there is no such thing for Java or C.


      holli, /regexed monk/