Abigail wrote:
> Before 5.6, lexical scoped file handles were possible, but everyone
> used globs, and the world didn't stop turning. Collision was so
> infrequent, noone wanted to type the few extra keystrokes.
Plus the ALL_CAPPED names really stood out, further decreasing
the chance of collision in programs with just one author. It
just never happened. 3rd-party modules are a different story,
and we were always rather more careful there.
> It's only when autovivifying handles came available everyone
> jumped on the "lexical filehandle" bandwagon.
Indeed.
> It's not worth having a style fight over for.
It's also quite a big job with negligible return value.
I tried to count up uses of lexical vs global handles in the pods.
I didn't consider those that were too hard to easily grep, like
print, printf, stat, and such. Here are the numbers:
Capped $dollared Ratio
pods 5.13.3 399 111 3.6 to 1
cookbook v2 359 215 1.7 to 1
camel v3+ 891 163 5.5 to 1
Not all those that are dollared are lexicals, and not all those that are
capped are not localized. But as a rough measure, it works well enough.
The v3 Camel didn't have autovivving filehandles, as Abigail
points out, which accounts for its somewhat larger ratio.
I figure just leave them be, as they really aren't harming anything,
and would be quite a pain to change: mere mindless busywork. I can
think of many, *much* better uses of that time and effort.
--tom
% tcgrep
'^\s[^#]*\b(open(dir)?|eof|binmode|getc|get(peername|sock(name|opt))|listen|write|fcntl|ioctl|flock|fileno|close(dir)?|read(line|dir)?|rewinddir|say|seek(dir)?|send|setsockopt|recv|sys(open|read|write|seek)|pipe|connect|accept|socket(pair)?|shutdown|tell(dir)?)\b\s*([({]\s*)?\$'
*.pod | wc -l
% tcgrep
'^\s[^#]*\b(open(dir)?|eof|binmode|getc|get(peername|sock(name|opt))|listen|write|fcntl|ioctl|flock|fileno|close(dir)?|read(line|dir)?|rewinddir|say|seek(dir)?|send|setsockopt|recv|sys(open|read|write|seek)|pipe|connect|accept|socket(pair)?|shutdown|tell(dir)?)\b\s*([({]\s*)?\p{Lu}'
*.pod | wc -l