From: Vincent Pit Date: Thu, 9 Apr 2015 17:16:18 +0000 (-0300) Subject: Factor the prefix cleaning logic in a new sanitize_prefix() helper X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=9b23c7dbe80c683a112687ab90cab1e3e1179eca;p=perl%2Fmodules%2FVPIT-TestHelpers.git Factor the prefix cleaning logic in a new sanitize_prefix() helper --- diff --git a/lib/VPIT/TestHelpers.pm b/lib/VPIT/TestHelpers.pm index 763c711..3225a1c 100644 --- a/lib/VPIT/TestHelpers.pm +++ b/lib/VPIT/TestHelpers.pm @@ -29,6 +29,20 @@ sub export_to_pkg { return 1; } +sub sanitize_prefix { + my $prefix = shift; + + if (defined $prefix) { + if (length $prefix and $prefix !~ /_$/) { + $prefix .= '_'; + } + } else { + $prefix = ''; + } + + return $prefix; +} + my %default_exports = ( load_or_skip => \&load_or_skip, load_or_skip_all => \&load_or_skip_all, @@ -225,17 +239,7 @@ sub fresh_perl_env (&) { } sub init_run_perl { - my $prefix = shift; - - if (defined $prefix) { - if (length $prefix and $prefix !~ /_$/) { - $prefix .= '_'; - } - } else { - $prefix = ''; - } - - my $p = $prefix; + my $p = sanitize_prefix(shift); return ( run_perl => \&run_perl,