Another thread yesterday reminded me that Open Has a New Trick.

But I'm wondering why. That is, I thought it was a Good Thing to move things out of the core and into modules. Here we have essentially IO::Scalar functionality moving into the core.

Wouldn't it be better to generally improve the filehandle tie ability or draw upon IO layers instead, and make IO::Scalar and IO::Stringy honor all the semantics, and perhaps even speed it up?

Is there some reason why this needs to go into the core, or was it just cool and easy? Does it go against the grain, so to speak?

—John

Replies are listed 'Best First'.
Re: WHY does 'open' have a new trick?
by Zaxo (Archbishop) on Nov 21, 2002 at 01:55 UTC

    It's certainly cool and easy :) The reason it's easy is that it fits in very well with how *nix thinks of files - as an ordered bag of bytes.

    Reading a file from disk involves pulling blocks of data off the wires and putting them in a memory buffer. If we just forget about the disk and write data into the buffer directly, what we get is just like a file, as far as the user is concerned.

    Getting perl to make use of that involved adding syntax to tell open that you want the new trick. Using a reference to a string was a brilliant choice, imo. It is compact, simple, and provides a natural way to set and recover the data.

    None of the above is informed by the actual implementation in PerlIO, just the general properties of *nix systems.

    After Compline,
    Zaxo

Re: WHY does 'open' have a new trick?
by shotgunefx (Parson) on Nov 21, 2002 at 01:21 UTC
    I believe it's there for a couple of reasons. It seems to me that it's there mainly because the PerlIO layer makes it easy to do (from what I understand, it is done using PerlIO) and it's much faster from what I've heard. I thought I remembered someone posting benchmarks to back this.

    -Lee

    "To be civilized is to deny one's nature."
    update
    This is the benchmark I was referring to.