I am facing some problem in perl recurssive function function
my @array_parent = (Some inegers);
my $outputfile = 'output.txt';
my $master_file = 'master.txt';
open (MASTER,"$>>master.txt");
foreach my $child (@array_parent){
my $line = `grep "$child" "$outputfile"`;
chomp($line);
chomp($child);
my @match = grep (/$child/i, @array_parent_level1);
if ($child == 22105201 ){
Lookup($line,*MASTER,$outputfile);
}
}
close(OUT);
close(MASTER);
sub Lookup {
my ($line,$MASTER,$outputfile)= @_;
my ($parent,$len);
open (OUT,"<$outputfile") or die "Can't OPen File $outputfile";
chomp($line);
$parent = (split /,/,$line)[8];
print "$parent\n";
$len = length($parent);
print "$len\n";
if ($len == 0) {
print "Please goto foreach\n";
return 1;
}
else{
while(<OUT>) {
chomp;
my $field = (split/,/)[6];
if ($field == $parent){
my $line = $_;
print "ok\n";
#print "$parent|$field|$line\n";
sleep(2);
Lookup($line,*MASTER,$outputfile);
}
}
}
}
After 3 time of Lookup function call, i am getting 0 is $len variable, it should be satisfied the condition and return 1 should execute, but function is calling infinite time.
Please do the needful expert