On 5/10/05, Uri Guttman <[EMAIL PROTECTED]> wrote:
> >>>>> "BT" == Ben Tilly <[EMAIL PROTECTED]> writes:
[...]
>   BT> Maintainability is more important than optimization.  I often use
>   BT> this strategy for maintainance reasons.  Going full-cycle, one way
>   BT> to accomplish all of this without changing code is to tie to a
>   BT> filehandle that accumulates data and prints it later.
> 
> but what if you don't want to print it but log it or send it to a
> message? what if you want a status sub to be useful in many different
> ways? making it use a handle or printing directly limits your
> flexibility and control. delaying printing until you are ready also
> means you can use write_file which is faster than print as it bypassed
> perlio.

With tie you can do all of that.  It may involve some hoops, but you
can do it.  You may need to write your own Tie class though.

The key point was "without changing code".  I should have been more
explicit about that.  This is a strategy to consider if you have existing
code and wish to refactor in a way which is inconsistent with how it
was intended to work.  I would not normally choose to write new
code on that plan.

As for performance, again I consider optimization less important
than maintainability until proven otherwise.  Besides, in my
experience the bulk of I/O time tends to be spent waiting for
resources (another process, filesystems etc) rather than stdio
buffering.

Cheers,
Ben
 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to