aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel/Shared.pm
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2014-06-22 23:44:29 +0200
committerAngelo Naselli <anaselli@linux.it>2014-06-22 23:44:29 +0200
commitc3ff29f9ad46d0cea6c94b44bcdb253d0f59f862 (patch)
treea1fa047ce0f4fd248f71cdb913505e16e73b62f1 /lib/AdminPanel/Shared.pm
parente3b75e7d53ccc3d59c1f81f3ca932a77f9bd3190 (diff)
downloadmanatools-c3ff29f9ad46d0cea6c94b44bcdb253d0f59f862.tar
manatools-c3ff29f9ad46d0cea6c94b44bcdb253d0f59f862.tar.gz
manatools-c3ff29f9ad46d0cea6c94b44bcdb253d0f59f862.tar.bz2
manatools-c3ff29f9ad46d0cea6c94b44bcdb253d0f59f862.tar.xz
manatools-c3ff29f9ad46d0cea6c94b44bcdb253d0f59f862.zip
Added parameter "separator" to know which is the tree item separator
into string
Diffstat (limited to 'lib/AdminPanel/Shared.pm')
-rw-r--r--lib/AdminPanel/Shared.pm19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/AdminPanel/Shared.pm b/lib/AdminPanel/Shared.pm
index dff57a72..a1df1149 100644
--- a/lib/AdminPanel/Shared.pm
+++ b/lib/AdminPanel/Shared.pm
@@ -194,8 +194,10 @@ sub md5sum {
=head3 INPUT
-paths: ARRAY of string containing path like strings
- (/ is the separator)
+$param : HASH ref containing
+ paths => ARRAY of string containing path like strings
+ separator => item separator inside a single path
+ (default separator is /)
=head3 OUTPUT
@@ -211,11 +213,20 @@ This function return a tree representation of the given array.
#=============================================================
sub pathList2hash {
+ my ($param) = @_;
+
+ die "array of path is missing" if ! exists $param->{paths};
+ my $separator = '/';
+ $separator = $param->{separator} if $param->{separator};
+ if ($separator eq "/" || $separator eq "|") {
+ $separator = '\\' . $separator;
+ }
+
my %tree;
- for (@_)
+ for (@{$param->{paths}})
{
my $last = \\%tree;
- $last = \$$last->{$_} for split /\//;
+ $last = \$$last->{$_} for split /$separator/;
}
return \%tree;