.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Acme::Brainfuck 3pm" .TH Acme::Brainfuck 3pm "2015-09-28" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Acme::Brainfuck \- Embed Brainfuck in your perl code .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #!/usr/bin/env perl \& use Acme::Brainfuck; \& \& print \*(AqHello world!\*(Aq, chr ++++++++++. ; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Brainfuck is about the tiniest Turing-complete programming language you can get. A language is Turing-complete if it can model the operations of a Turing machine\*(--an abstract model of a computer defined by the British mathematician Alan Turing in 1936. A Turing machine consists only of an endless sequence of memory cells and a pointer to one particular memory cell. Yet it is theoretically capable of performing any computation. With this module, you can embed Brainfuck instructions delimited by whitespace into your perl code. It will be translated into Perl as parsed. Brainfuck has just just 8 instructions (well more in this implementation, see \*(L"Extensions to \s-1ANSI\s0 Brainfuck\*(R" below.) which are as follows .SS "Instructions" .IX Subsection "Instructions" .IP "+ Increment" 4 .IX Item "+ Increment" Increase the value of the current memory cell by one. .IP "\- Decrement" 4 .IX Item "- Decrement" Decrease the value of the current memory cell by one. .IP "> Forward" 4 .IX Item "> Forward" Move the pointer to the next memory cell. .IP "< Back" 4 .IX Item "< Back" Move the pointer to the previous memory cell. .IP ", Input" 4 .IX Item ", Input" Read a byte from Standard Input and store it in the current memory cell. .IP ". Output" 4 .IX Item ". Output" Write the value of the current memory cell to standard output. .IP "[ Loop" 4 .IX Item "[ Loop" If the value of the current memory cell is 0, continue to the cell after the next ']'. .IP "] Next" 4 .IX Item "] Next" Go back to the last previous '['. .SS "Extensions to \s-1ANSI\s0 Brainfuck" .IX Subsection "Extensions to ANSI Brainfuck" This implementation has extra instructions available. In order to avoid such terrible bloat, they are only available if you use the \fIverbose\fR pragma like so: .PP use Acme::Brainfuck qw/verbose/; .PP The extra instructions are: .IP "~ Reset" 4 .IX Item "~ Reset" Resets the pointer to the first memory cell and clear all memory cells. .IP "# Peek" 4 .IX Item "# Peek" Prints the values of the memory pointer and the current memory cell to \&\s-1STDERR. \s0 See also \*(L"Debugging\*(R" below. .SS "Debugging" .IX Subsection "Debugging" By using the \fIdebug\fR pragma like this: .PP use Acme::Brainfuck qw/debug/; .PP you can dump out the generated perl code. (Caution: it is not pretty.) The key to understanding it is that the memory pointer is represented by \&\fI\f(CI$p\fI\fR, and the memory array by \fI\f(CI@m\fI\fR Therefore the value of the current memory cell is \fI\f(CI$m\fI[$p]\fR. .SH "RETURN VALUE" .IX Header "RETURN VALUE" Each sequence of Brainfuck instructions becomes a Perl block and returns the value of the current memory cell. .SH "EXAMPLES" .IX Header "EXAMPLES" .SS "\s-1JABH\s0" .IX Subsection "JABH" .Vb 10 \& #!/usr/bin/env perl \& use Acme::Brainfuck; \& print "Just another "; \& ++++++[>++++++++++++++++<\-]> \& ++.\-\- \& >+++[<++++++>\-]<.>[\-]+++[<\-\-\-\-\-\->\-]< \& +.\- \& +++++++++.\-\-\-\-\-\-\-\-\- \& ++++++++++++++.\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& ++++++.\-\-\-\-\-\- \& >+++[<+++++++>\-]<.>[\-]+++[<\-\-\-\-\-\-\->\-]< \& +++.\-\-\- \& +++++++++++.\-\-\-\-\-\-\-\-\-\-\- \& print " hacker.\en"; .Ve .SS "Countdown" .IX Subsection "Countdown" .Vb 3 \& #!/usr/bin/env perl \& use strict; \& use Acme::Brainfuck qw/verbose/; \& \& print "Countdown commencing...\en"; \& ++++++++++[>+>+<<\-] \& >>+++++++++++++++++++++++++++++++++++++++++++++++<< \& ++++++++++[>>.\-<.<\-] \& print "We have liftoff!\en"; .Ve .SS "Reverse" .IX Subsection "Reverse" .Vb 2 \& #!/usr/bin/env perl \& use Acme::Brainfuck qw/verbose/; \& \& while(1) \& { \& print "Say something to Backwards Man and then press enter: "; \& +[\->,\-\-\-\-\-\-\-\-\-\-]< \& print \*(AqBackwards Man says, "\*(Aq; \& [+++++++++++.<]< \& print "\e" to you too.\en"; \& ~ \& } .Ve .SS "Math" .IX Subsection "Math" .Vb 4 \& #!/usr/bin/env perl \& use Acme::Brainfuck; \& use strict; \& use warnings; \& \& my $answer = +++[>++++++<\-]> ; \& \& print "3 * 6 = $answer \en"; .Ve .SH "VERSION" .IX Header "VERSION" .Vb 1 \& 1.1.1 Apr 06, 2004 .Ve .SH "AUTHOR" .IX Header "AUTHOR" .Vb 1 \& Jaldhar H. Vyas Ejaldhar@braincells.comE .Ve .SH "THANKS" .IX Header "THANKS" Urban Mueller \- The inventor of Brainfuck. .PP Damian Conway \- For twisting perl to hitherto unimaginable heights of weirdness. .PP Marco Nippula \- Some code in this module comes from his \fIbrainfuck.pl\fR .PP Mr. Rock \- Who has a nice Brainfuck tutorial at . Some of the example code comes from there. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" .Vb 2 \& 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." .Ve