Created
October 17, 2010 13:40
-
-
Save karronoli/630865 to your computer and use it in GitHub Desktop.
simple text template
This file contains hidden or 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
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