N
nicolas-laurent
Hello world,
Can anybody help me understand what does the following subroutine do?
I dont understand the syntax 1. my $res = ""; 2. $sub = "\\."; and not
sure what it does exactly. Thanks for your help.
sub unrollExcTree {
my ($alias, $conf) = @_;
my $res = "";
my $sub;
#printc "unroll $alias";
# main alias like DERT
if ($alias =~ /^[A-Z_]+$/m) {
$sub = "";
}
# sub alias like DERT19.2 or DERT3
elsif ($alias =~ /^[A-Z_]+\d+\.\d+$/m) {
$sub = "";
}
else {
$sub = "\\.";
}
#printc "sub=$sub", 'blue';
while (my ($a, $re) = each (%$conf)) {
#trc("$a =~ /^$alias$sub/");
if ($a =~ /^$alias$sub/m) {
$res .= "$a,";
#trc("found $a", '', 'green');
}
}
if ($res eq '') {
$res = $alias;
}
else {
$res = substr($res, 0, length($res)-1);
}
#trc("res=$res"); die;
return $res;
}
Can anybody help me understand what does the following subroutine do?
I dont understand the syntax 1. my $res = ""; 2. $sub = "\\."; and not
sure what it does exactly. Thanks for your help.
sub unrollExcTree {
my ($alias, $conf) = @_;
my $res = "";
my $sub;
#printc "unroll $alias";
# main alias like DERT
if ($alias =~ /^[A-Z_]+$/m) {
$sub = "";
}
# sub alias like DERT19.2 or DERT3
elsif ($alias =~ /^[A-Z_]+\d+\.\d+$/m) {
$sub = "";
}
else {
$sub = "\\.";
}
#printc "sub=$sub", 'blue';
while (my ($a, $re) = each (%$conf)) {
#trc("$a =~ /^$alias$sub/");
if ($a =~ /^$alias$sub/m) {
$res .= "$a,";
#trc("found $a", '', 'green');
}
}
if ($res eq '') {
$res = $alias;
}
else {
$res = substr($res, 0, length($res)-1);
}
#trc("res=$res"); die;
return $res;
}