Joyful Perl 6
I was reading through the source code for proto over a beer this evening and came across this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} |
That's some serious Joy :)
No comments:
Post a Comment