Execute Brain****/Perl: Difference between revisions

Content added Content deleted
(Created page.)
 
(Cleaned up scoping of $input_buffer)
Line 39: Line 39:
']' => sub { $cmd = pop(@loops) - 1 });
']' => sub { $cmd = pop(@loops) - 1 });


$main::input_buffer = ''; # Where we store each line of input.
{my $input_buffer = ''; # Where we store each line of input.
sub get_input
sub get_input
# Gets one character of input and returns its numeric value.
# Gets one character of input and returns its numeric value.
{our $input_buffer;
{$input_buffer or $input_buffer = <STDIN>;
$input_buffer or $input_buffer = <STDIN>;
return defined($input_buffer)
return defined($input_buffer)
? ord substr($input_buffer, 0, 1, '')
: $eof_val;}}
? ord substr($input_buffer, 0, 1, '')
: $eof_val;}


sub jump
sub jump