Acme-Coro-Suke
view release on metacpan or search on metacpan
inc/IO/Scalar.pm view on Meta::CPAN
#line 1
package IO::Scalar;
#line 147
use Carp;
use strict;
use vars qw($VERSION @ISA);
use IO::Handle;
use 5.005;
### Stringification, courtesy of B. K. Oxley (binkley): :-)
use overload '""' => sub { ${*{$_[0]}->{SR}} };
use overload 'bool' => sub { 1 }; ### have to do this, so object is true!
### The package version, both in 1.23 style *and* usable by MakeMaker:
$VERSION = "2.110";
### Inheritance:
@ISA = qw(IO::Handle);
### This stuff should be got rid of ASAP.
require IO::WrapTie and push @ISA, 'IO::WrapTie::Slave' if ($] >= 5.004);
#==============================
#line 175
#------------------------------
#line 185
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = bless \do { local *FH }, $class;
tie *$self, $class, $self;
$self->open(@_); ### open on anonymous by default
$self;
}
sub DESTROY {
shift->close;
}
#------------------------------
#line 210
sub open {
my ($self, $sref) = @_;
### Sanity:
defined($sref) or do {my $s = ''; $sref = \$s};
(ref($sref) eq "SCALAR") or croak "open() needs a ref to a scalar";
### Setup:
*$self->{Pos} = 0; ### seek position
*$self->{SR} = $sref; ### scalar reference
$self;
}
#------------------------------
#line 232
sub opened {
*{shift()}->{SR};
}
#------------------------------
#line 246
sub close {
my $self = shift;
%{*$self} = ();
1;
}
#line 256
#==============================
#line 266
#------------------------------
#line 276
sub flush { "0 but true" }
#------------------------------
( run in 2.151 seconds using v1.01-cache-2.11-cpan-d7f47b0818f )