Acme-Brainfuck

 view release on metacpan or  search on metacpan

lib/Acme/Brainfuck.pm  view on Meta::CPAN

This implementation has extra instructions available.  In order to avoid such
terrible bloat, they are only available if you use the I<verbose> pragma like 
so:

use Acme::Brainfuck qw/verbose/;

The extra instructions are:

=over 4

=item ~ Reset

Resets the pointer to the first memory cell and clear all memory cells.

=item # Peek

Prints the values of the memory pointer and the current memory cell to 
STDERR.  See also L</"Debugging"> below.

=back

=head2 Debugging

t/1.t  view on Meta::CPAN

	$class;
}

sub FILENO {
	my $class = shift;
	return $class->{FILENO};
}

sub WRITE {
	my $class = shift;
	my($buf,$len,$offset) = @_;
        $offset = 0 if (! defined $offset);
    	my $data = substr($buf, $offset, $len);
    	my $n = length($data);
    	$class->print($data);
        return $n;
}

sub PRINT {
	my $class = shift;
        ${$class->{data}} .= join('', @_);
    	$class->{position} = length(${$class->{data}});
    	1;

t/1.t  view on Meta::CPAN


sub PRINTF {
	my $class = shift;
	my $fmt = shift;
	$class->PRINT(sprintf $fmt, @_);
}

sub READ {
	my $class = shift;

	my ($buf,$len,$offset) = @_;
    	$offset = 0 if (! defined $offset);

    	my $data = ${ $class->{data} };

    	if ($class->{end} >= length($data)) {
		return 0;
	}
	$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;
	}



( run in 1.179 second using v1.01-cache-2.11-cpan-49f99fa48dc )