Acme-Brainfuck
view release on metacpan or search on metacpan
}
$buf = substr($data,$offset,$len);
$_[0] = $buf;
$class->{end} += length($buf);
return length($buf);
}
sub READLINE {
my $class = shift;
if ($class->{end} >= length(${ $class->{data} })) {
return undef;
}
my $recsep = $/;
my $rod = substr(${ $class->{data} }, $class->{end}, -1);
$rod =~ m/^(.*)$recsep{0,1}/; # use 0,1 for line sep to include possible no \n on last line
my $line = $1 . $recsep;
$class->{end} += length($line);
return $line;
}
sub CLOSE {
my $class = shift;
if (-e $class->{tmpfile}) {
$class->{fh}->close();
unlink $class->{tmpfile} or warn $!;
}
$class = undef;
1;
}
sub DESTROY {
my $class = shift;
if (-e $class->{tmpfile}) {
unlink $class->{tmpfile} or warn $!;
}
$class = undef;
1;undef $class;
}
( run in 1.168 second using v1.01-cache-2.11-cpan-d80b1682f3f )