Acme::Brainfuck(3pm)
π NAME π
Acme::Brainfuck β bestie, this is the module that lets you embed Brainfuck right inside your perl code. Yes fr fr. It's in the Acme:: namespace on perl's user-contributed docs, iykyk.
β¨ SYNOPSIS β¨
#!/usr/bin/env perl
use Acme::Brainfuck;
print 'Hello world!', chr ++++++++++. ;
okay so that's literally it. you drop the symbols in and it just works. no cap. π
π§ DESCRIPTION π§
So. Brainfuck is like the tiniest Turing-complete programming language you can possibly get β it's giving minimalist queen π. And a language is Turing-complete if it can model the operations of a Turing machine, which is that abstract model of a computer the British mathematician Alan Turing defined back in 1936.
A Turing machine is literally just an endless sequence of memory cells plus a pointer to one particular memory cell. That's the whole thing. And yet it's theoretically capable of performing any computation. wild.
With this module, you get to embed Brainfuck instructions into your perl code, delimited by whitespace. It'll be translated into Perl as parsed. Brainfuck has just just 8 instructions (well, more in this implementation β see "Extensions to ANSI Brainfuck" below π«Ά) which are as follows:
πΈ Instructions πΈ
+Increment β bump the value of the current memory cell up by one.-Decrement β drop the value of the current memory cell down by one.>Forward β move the pointer to the next memory cell.<Back β move the pointer to the previous memory cell.,Input β read a byte from Standard Input and stash it in the current memory cell..Output β write the value of the current memory cell to standard output.[Loop β if the value of the current memory cell is 0, continue to the cell after the next].]Next β go back to the last previous[.
π¦ Extensions to ANSI Brainfuck π¦
This implementation has extra instructions available. But bestie, in order to avoid such terrible bloat, they are only available if you use the verbose pragma, like so:
use Acme::Brainfuck qw/verbose/;
The extra instructions are:
~Reset β resets the pointer to the first memory cell and clear all memory cells.#Peek β prints the values of the memory pointer and the current memory cell toSTDERR. See also "Debugging" below.
π Debugging π
By using the debug pragma like this:
use Acme::Brainfuck qw/debug/;
you can dump out the generated perl code. (Caution: it is not pretty. π it's giving unhinged but we respect it.) The key to understanding it is that the memory pointer is represented by $p, and the memory array by @m. Therefore the value of the current memory cell is $m[$p]. periodt.
π« RETURN VALUE π«
Each sequence of Brainfuck instructions becomes a Perl block and returns the value of the current memory cell. cute, right?
π₯ EXAMPLES π₯
π JABH
#!/usr/bin/env perl
use Acme::Brainfuck;
print "Just another ";
++++++[>++++++++++++++++<-]>
++.--
>+++[<++++++>-]<.>[-]+++[<------>-]<
+.-
+++++++++.---------
++++++++++++++.--------------
++++++.------
>+++[<+++++++>-]<.>[-]+++[<------->-]<
+++.---
+++++++++++.-----------
print " hacker.\n";
β Countdown
#!/usr/bin/env perl
use strict;
use Acme::Brainfuck qw/verbose/;
print "Countdown commencing...\n";
++++++++++[>+>+<<-]
>>+++++++++++++++++++++++++++++++++++++++++++++++<<
++++++++++[>>.-<.<-]
print "We have liftoff!\n";
π§ Reverse
#!/usr/bin/env perl
use Acme::Brainfuck qw/verbose/;
while(1)
{
print "Say something to Backwards Man and then press enter: ";
+[->,----------]<
print 'Backwards Man says, "';
[+++++++++++.<]<
print "\" to you too.\n";
~
}
π Math
#!/usr/bin/env perl
use Acme::Brainfuck;
use strict;
use warnings;
my $answer = +++[>++++++<-]> ;
print "3 * 6 = $answer \n";
π VERSION π
1.1.1 Apr 06, 2004
π AUTHOR π
Jaldhar H. Vyas jaldhar@braincells.com β icon, legend, the moment.
π«Ά THANKS π«Ά
- Urban Mueller β The inventor of Brainfuck. respect the founder fr fr.
- Damian Conway β For twisting perl to hitherto unimaginable heights of weirdness. honestly iconic behaviour.
- Marco Nippula
http://www.hut.fi/~mnippula/β Some code in this module comes from hisbrainfuck.pl. ty bestie π₯Ή - Mr. Rock β Who has a nice Brainfuck tutorial at
http://www.cydathria.com/bf/. Some of the example code comes from there.
π COPYRIGHT AND LICENSE π
Copyright (c) 2004, Consolidated Braincells Inc.
Licensed with no warranties under the Crowley Public License:
"Do what thou wilt shall be the whole of the license."
no warranties, bestie. do what thou wilt. that's the whole license. that's it. π
okay and for the cute sign-off: this whole page came to you via perl v5.32.0, dated 2021-01-06, filed under Acme::Brainfuck(3pm) in the User Contributed Perl Documentation. slay, go write something cursed, mwah π¦β¨π
π¦ where this page comes from
- debian bookworm: libacme-brainfck-perl 1.1.1-2.1 Β· Crowley-Public-License
- debian trixie: libacme-brainfck-perl 1.1.1-2.1 Β· Crowley-Public-License
- ubuntu jammy: libacme-brainfck-perl 1.1.1-2.1 Β· Crowley-Public-License
- ubuntu noble: libacme-brainfck-perl 1.1.1-2.1 Β· Crowley-Public-License
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms