Skip to content

Instantly share code, notes, and snippets.

# Makefile creator in Perl 6, reads Makefile.in and writes Makefile.
# Use your values of /my/ to run either (always in current directory):
# '/my/perl6 Makefile.p6' or '/my/parrot /my/perl6.pbc Makefile.p6'
use v6;
# say %*VM<config>.perl;
# say "osname = {%*VM<config><osname>}";
# say "revision = {%*VM<config><revision>}";
# say "MAJOR.MINOR.PATCH = {%*VM<config><MAJOR>}.{%*VM<config><MINOR>}.{%*VM<config><PATCH>}";
# say "prefix = {%*VM<config><prefix>}";
Pod::Parser performance (therefore also Pod::Server) is disappointingly
slow when handling medium size (5k-50k) files. Memory usage climbs rapidly
because it seems Parrot or Rakudo leaks memory until the process exits.
The operating system resorts to swapping hectically in a hopeless effort
to provide more, but Parrot doesn't recycle and keeps calling malloc().
After almost hanging the computer for a long time the kernel usually kills
the Parrot.
Running L<Pod::Server|http://github.com/eric256/perl6-examples/blob/master/lib/Pod/Server.pm>
#!/bin/bash
#
# NAME
# hello.bash - a canonical "hello, world!" project for proto
#
# SYNOPSIS
# bash hello.bash # creates and uploads everything in /tmp/hello
#
# DESCRIPTION
# Implements proto's PIONEER plan in code
sub socket( IO $socket, Int $domain, Int $type, Int $protocol ) {
return q:PIR{ # from q:PIR in socket() in Daemon.pm
.local pmc sock
.local int domain
.local int type
.local int protocol
find_lex $P0, "$socket" # handle to be opened
find_lex $P1, "$domain" # 2=PF_INET (read 'man socket')
find_lex $P2, "$type" # 1=SOCK_STREAM ?=SOCK_DGRAM
sub socket( IO $socket, Int $domain, Int $type, Int $protocol ) {
return Q:PIR{ # from q:PIR in socket() in Daemon.pm
.local pmc sock
.local int domain
.local int type
.local int protocol
find_lex sock, "$socket" # socket object
find_lex $P0, "$domain" # 2=PF_INET (read 'man socket')
find_lex $P1, "$type" # 1=SOCK_STREAM ?=SOCK_DGRAM
find_lex $P2, "$protocol" # is 6=tcp ?=udp
#!/usr/local/bin/perl6
# sockets-test.pl - trying out Parrot sockets from Rakudo
# Interim subs for Parrot (r37707) socket functions (PDD 22) in Rakudo.
# Later, when this code moves to rakudo/src/setting/IO.pm, the 'sub'
# definitions will become 'method' to augment the IO class.
# Later still, the socket functions in Parrot will disappear because
# they are deprecated, to be replaced by methods on ParrotIO objects.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>S28-special-names.pod</title>
<style type="text/css">
h1 { font-family: Sans; }
table { }
td { vertical-align: top; }
td#pod { border-style: solid; width: 100%; }
td#pod > pre { font-size: 8pt; }
=== KEEP ===
* 0-based versus 1-based
** Month, day-of-month, day-of-week, day-of-year are all 1-based.
** All time-based ones are 0-based.
** Year is neither.
* Constructor:
#!/usr/bin/perl -w
# process-monitor.pl
# Only tested on Linux - uses the /proc virtual filesystem
use Getopt::Long;
use Time::HiRes;
my (
$sampling_interval, # interval for sampling process info (0.1sec)
$display_interval # interval for displaying results (off)
martin@meee:~/fakedbi$ cat postgresqlclient.p6
# postgresql test example 1 translated from C to Perl 6
# See http://www.postgresql.org/docs/9.0/static/libpq-example.html
# and more comments below.
use NativeCall; # from project 'zavolaj'
# -------- foreign function definitions in alphabetical order ----------
sub PQclear( OpaquePointer $res )