Well, the post was all tongue in cheek, but to break character here, the select() idiom was something I came up with one day when I was trying to unbuffer an arbitrary filehandle, regardless of the currently selected filehandle. Since I had invented the literal slice notation, I wondered if that could be used there to eliminate the normal temporary variable by holding the previous handle as part of the constructed list. And boom, there it was.
The problem is that its obscurity offsets any useful gain over just writing it as a normal two or three step process.
Another way to do it without using a "temporary" variable might be something like:
for (select(HANDLETOUNBUFFER)) {
$|++;
select($_);
}
But I'd argue this is just as obscure.
Moral of the story: it's ok to say my $old = select(NEW); when you need the old handle. It's fine. Don't worry. Be happy.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply. |