Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Alias (5735)

  (email not shown publicly)

Journal of Alias (5735)

Saturday May 06, 2006
05:55 PM

Almost time to abandon IO::Scalar for IO::String

[ #29540 ]

It's time to give IO::Scalar the big goodbye. (well, at least after one last bug fix)

The problem is that it doesn't behave like an IO::Handle properly. It's sorta kinda the same, but sufficiently different that you should expect it will break on you eventually.

IO::String on the other hand, is smaller, lighter, doesn't come with 5 other related modules who's tests could fail and block you, and behaves EXACTLY like a filehandle, even down to its seek-past-end-of-file behaviour.

And more importantly, that means it actually works with modules like Archive::Zip that care about seeking. If you currently use IO::Scalar, your module won't work properly with Archive::Zip.

I tried porting over Archive::Builder a couple of days ago as part of my own effort to move all of my CPAN modules over, and in that case it was a simple s/IO::Scalar/IO::String/ and everything Just Worked.

So if your CPAN module uses IO::Scalar currently, consider moving. It may seem a small thing, but it means your module will be able to Play Well With Others much more cleanly.

That is all. :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Since 5.8.0, Perl can do this natively:
      open my $fh, '>', \my $str;
    That does the same thing as IO::Scalar and IO::String.


    • That approach is fine if you don't care about anything older than 5.8.0 (which rules out all non-Unicode CPAN modules).

      While CPAN is just barely turning the corner and discarding 5.005 and use 5.6 as the new base version, it's nowhere near ready for a 5.8 minimum.

      Now for another few years at least.

      And worse, you can't validate the damned things either.

      DB $str = 'foo';