[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Cool hack of the week




> er, pardon my [possible] ignorance, but what's so hard about $|++ ?

It only works on the currently-selected filehandle.  So you have to
use select to select the filehandle for which you want to set
autoflushing, and then you have to use select to set it back again,
and you have to store the old selected filehandle in an otherwise
useless variable in between.  All of which turns what should be a
simple operation into a four or five-line locution.

This is why people invented this:
> >  select((select(FH), $|++)[0]);

and this:

> > FH->autoflush(1);

The existience and wide advertisement of these two locutions shows
that whatever &you* might think about the simplicity and convenience
of $|++, many other people don't share your opinions.  

> i can only see this as advantageous if:

For one-off scripts it's probably a waste of time.  But in a one-off
script almost everything is a waste of time.

On the other hand, the cost is *extremely* low, and the new feature is
almost identical to the standard, well-known facility.

You also left out a possible advantage: the ->autoflush() syntax is
less cryptic than either $|++; or { my $o = select FH; $|++; select $o }.


>    and

Or.




==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org