in reply to Re^4: File open problem with "GLOB"
in thread File open problem with "GLOB"

Sure, and there's no need to use strict or warnings if you don't ever make any typos.

I put the curlies around the filehandle even in the simple case, because once I get out of the habit, I'll spend way too long debugging a filehandle in a complex expression that, for some baffling reason, refuses to work... and I know why the Perl 5 parser has a problem here. If that trips me up, I suspect it may also trip up the fair few Perl 5 programmers who haven't read the Perl 5 source code.

Replies are listed 'Best First'.
Re^6: File open problem with "GLOB"
by ikegami (Patriarch) on Mar 16, 2008 at 07:14 UTC

    Your comparison to strict and warnings is flawed. When those are off, the program usually fails in subtle ways. When you use a "complex" handle expression without curlies, you get a syntax error in the expression. I find it hard to believe it takes "way too long" to debug an error when the exact location is provided to you.

    I don't see what having seen the perl source has to do with this. Half (4 out of 11 lines) of print's documentation covers the fact that the curlies are needed for "complex" handle expressions. I strongly advocate against using indirect method invocation anywhere else.

    So all that's left is the argument that you might trip in the future. I understand the argument. I advocated split // over split "" elsewhere in this thread for the this very reason. However, given how unsubtle the error is when you do trip, I see that positive outweighed by the fact you're asking newcomers write code differently than everyone else. I'm not saying noone uses curlies, but that I've never seen anyone use curlies for a simple scalar before. If more people used the curlies, I'd advocate them.