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

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']});

Replies are listed 'Best First'.
Re^3: Strange finish!!
by holli (Abbot) on Nov 07, 2007 at 13:26 UTC
    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.
        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/