|Subject:||Suggested policy: comma instead of semicolon|
I was surprised that perlcritic didn't catch the following mistake: print 'a', print 'b'; That first comma was intended to be a semicolon. Perl itself also gives no warning for this. I can think of a few possible policies that would catch it: - If a line ends with a comma, the next line should be indented. - Although the return code from the print() and say() builtins can be checked, it should not itself be printed directly. - print() and say() and perhaps other builtins should appear only as the left-hand part of an expression or statement. This would forbid stuff like $j = ($i++ && print 'hello') but (somehow) when print appears leftmost, as print('hello') || die then it would be allowed. What do you think? The indentation check is the most straightforward and I think would quickly catch bugs, but it may be a new departure for perlcritic to issue warnings based on code layout.