I have a perl code that runs like
Code I
sub p
{
if ($d >= $D) {return}
printf "%3s"x$d++," ";
printf "%s%s\n",$_[0],$h{$_[0]}?" ** ":"";
if (!$h{$_[0]})
{
$h{$_[0]}=1;
map {p($_)} @{$s{$_[0]}}
}
$d--
}
($Set,$Job,$Num,$D) = (@ARGV);
map {shift} 0..3;
while (<>)
{
map {push @{$s{"$pS,$pJ,$pN"}},"$sS,$sJ,$sN"} {($sS,$sJ,$sN,$pJ,$pS,$pN) = (/DEFINE JOBPRED ID=.(\S+),(\S+),(\d+). PJOB=(\S+) PSET=(\S+) PJNO=(\S+).*/)}
}
Code II
sub p
{
if ($d >= $D) {return}
printf "%3s"x$d++," ";
printf "%s%s\n",$_[0],$h{$_[0]}?" ** ":"";
if (!$h{$_[0]})
{
$h{$_[0]}=1;
map {p($_)} @{$s{$_[0]}}
}
$d--
}
($Set,$Job,$Num,$D) = (@ARGV);
map {shift} 0..3;
while (<>)
{
map {push @{$s{"$sS,$sJ,$sN"}},"$pS,$pJ,$pN"} {($sS,$sJ,$sN,$pJ,$pS,$pN) = (/DEFINE JOBPRED ID=.(\S+),(\S+),(\d+). PJOB=(\S+) PSET=(\S+) PJNO=(\S+).*/)}
}
p("$Set,$Job,$Num");
I need to convert this to UNIX Shell (perhaps using awk/sed ?). Could you please advise.
I hope there is sufficient information here.