Blame SOURCES/roffexpandvar

fca7bd
#!/usr/bin/perl
fca7bd
use strict;
fca7bd
use warnings;
fca7bd
fca7bd
my %variables = @ARGV;
fca7bd
my %replacements;
fca7bd
while (my ($key, $value) = each %variables) {
fca7bd
	$key = qr{$key};
fca7bd
	$value =~ s/'/\\[aq]/g;
fca7bd
	$value =~ s/-/\\N'45'/g;
fca7bd
	$replacements{$key} = $value;
fca7bd
}
fca7bd
fca7bd
while(<STDIN>) {
fca7bd
	while (my ($source, $target) = each %replacements) {
fca7bd
		$_ =~ s/$source/$target/g;
fca7bd
	}
fca7bd
	print $_;
fca7bd
}