Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
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.

    -Dom

    • 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';
                                                                                                                                                                                                                                                                                                      DB open $fh, '>', \my $str;
                                                                                                                                                                                                                                                                                                      DB x $fh
      0 GLOB(0x851ca94)
            -> *main::$fh
                        FileHandle({*main::$fh}) => fileno(-1)
                                                                                                                                                                                                                                                                                                      DB x $fh->isa('IO::Seekable')
      0 ''

      So if you goal is to accept params that are seekable handles... well it at least appears that a modern IO::String-alike is not a seekable filehandle.

      Of course, if you can answer the question "is seekable" comprehensively and _provably_, there's a lot of beer in it for you :)