Skip to content

Instantly share code, notes, and snippets.

@karronoli
Created October 17, 2010 13:40
Show Gist options
  • Save karronoli/630865 to your computer and use it in GitHub Desktop.
Save karronoli/630865 to your computer and use it in GitHub Desktop.
simple text template
use strict;
use warnings;
use utf8;
print sub {
my %arg = @_;
my ($k, $v, $in) =
($arg{keyword}, $arg{value}, $arg{input});
my $i = index($in, $k);
if($i == -1) {
return $in;
} else {
do {
$in = $v . substr($in, $i + length($k));
} while($i = (index($in, $k) != -1));
}
return $in;
}->(keyword=>'%PREFIX', value=>'/home/karronoli', input=>'%PREFIX/usr/local');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment