Last active
June 4, 2017 00:45
-
-
Save ramonvictor/dc7dce97913a9a313a113bfb85509a08 to your computer and use it in GitHub Desktop.
This file contains 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 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