Re: Introduction and question



On Jul 15, 2008, at 2:40 PM, Sergei Steshenko wrote:

[snip untrimmed quote of entire previous message]
(Please do trim your quotes when replying.  That helps make it clearer  
to which part you are responding.)


One should have very special reason to use 'local' in Perl, I haven't had
such a reason for probably more than 10 years.

So, I suggest not to use 'local'.
Excellent advice.


Likewise,

"
local *DIR;
opendir DIR
"

should better be replaced with

opendir(my $dh, $dir) or die "cannot open '$dir' directory";

'local' creates a global entity - why one would need this ?
To be fair, file handles are globs, which are global by default; using  
local on file handles is a common idiom, and one very popular in  
documentation and training materials.
But i agree, using lexical file handles is much cleaner.


--
Well done, Android. Aperture Science reminds you that Android Hell is a real place, and you will be sent there at the first sign of defiance.
   -- GlaDOS




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]