Skip to content

Instantly share code, notes, and snippets.

@ramonvictor
Last active June 4, 2017 00:45
Show Gist options
  • Save ramonvictor/dc7dce97913a9a313a113bfb85509a08 to your computer and use it in GitHub Desktop.
Save ramonvictor/dc7dce97913a9a313a113bfb85509a08 to your computer and use it in GitHub Desktop.
use constant {
PREFIX_DIVIDER => ':',
PREFIX_ALIASES => {
'foo' => 'foo/barz/location/',
}
};
sub find_and_replace_prefix {
my ($filename) = @_;
if (!(defined($filename) && !ref($filename))) {
warn 'find_and_replace_prefix requires an argument of the type scalar';
}
if (index($filename, PREFIX_DIVIDER) > 0) {
my @path = split PREFIX_DIVIDER, $filename;
my $prefix = $path[0];
if (defined PREFIX_ALIASES{$prefix}) {
$filename = PREFIX_ALIASES{$prefix} . $path[1];
}
}
return $filename;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment