The Myth of the Muttering Madman is a project in self-realization.

Monday, November 09, 2009

Joyful Perl 6

I was reading through the source code for proto over a beer this evening and came across this:

# Read Makefile.in, edit, write Makefile
my $maketext = slurp( 'Makefile.in' );
$maketext .= subst( .key, .value ) for
'Makefile.in' => 'Makefile',
'To be read' => 'Written',
'replaces <TOKENS>' => 'defined these',
# Maintainer note: keep the following in sync with pod#VARIABLES below
'<PERL6>' => $perl6,
'<PERL6LIB>' => $perl6lib,
'<PERL6BIN>' => $perl6bin,
'<RAKUDO_DIR>' => $rakudo_dir;
squirt( 'Makefile', $maketext );
# Job done.
.say for
'',
q[Makefile is ready, and you can run 'make'.];
# The opposite of slurp
sub squirt( Str $filename, Str $text ) {
my $handle = open( $filename, :w )
or die $!;
$handle.print: $text;
$handle.close;
}
view raw Perl 6 Joy.p6 hosted with ❤ by GitHub


That's some serious Joy :)

No comments:

about me