Before you can run any examples, you'll need to download the latest version of Parrot. If you don't have a compiler, some binary packages are available.

Once you have a parrot executable, check out the PIR and PASM examples. Also, be sure to check out the examples directory in the Parrot repository.

Example Conventions

As you read through the examples, you'll see the following typographic conventions:

Code snippets will appear in blue:


Expected output will appear in green:


Occasionally, additional information will be presented in red: take note!

Help! I'm stuck inside a fortune cookie factory!

Running Examples

For all of the examples, you can save the code in a file (PIR examples use a .pir suffix, PASM examples use a .pasm suffix.). Then you can either run the sample directly:

parrot foo.pir

Or, you can compile to bytecode and then run it:

parrot -o foo.pbc foo.pir
parrot foo.pbc