Skip to content

Instantly share code, notes, and snippets.

@snarkyboojum
Created November 9, 2009 08:10
Show Gist options
  • Save snarkyboojum/229775 to your computer and use it in GitHub Desktop.
Save snarkyboojum/229775 to your computer and use it in GitHub Desktop.
# 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment