Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 38 lines (31 sloc) 0.668 kb
#!/usr/bin/perl
use strict;
use English;
my %snippets = ();
foreach my $filename (@ARGV[0 .. $#ARGV - 1]) {
open FILE, $filename or die;
while (<FILE>) {
if (/^\/\* TEMPLATE (\w+) \*\/$/) {
my $name = $1;
my $snippet = "";
while (1) {
$_ = <FILE> or die;
last if /^\/\* END \*\/$/;
$snippet .= $_;
}
$snippets{$name} = $snippet;
}
}
close FILE;
}
open FILE, $ARGV[-1] or die;
while (<FILE>) {
my $line = $_;
while ($line =~ /\$def_(\w+)/) {
my $name = $1;
exists $snippets{$name} or die "Snippet $name not found";
$line = $PREMATCH . $snippets{$name} . $POSTMATCH;
}
print $line;
}
close FILE;
Jump to Line
Something went wrong with that request. Please try again.