in reply to Re^3: Recursive search
in thread Recursive search

Thanks cdark and corion but when I open the filehandle I only see the first line in the file getting stored,confused on what is wrong?
my $plf = shift; print "\nPLF in recursion:$plf\n"; open my $fh, '<', $plf or die "could not open '$plf' $!"; foreach (my $line = <$fh>) { print "LINE:$line"; #prints ,just the first line if($line =~ /\/(.+?\.plf)$/) { print "LINE CONDITION:$line"; #never comes here #print $1; $match_plf_name = $1; next if $match_plf_name eq $plf; push @recursive_plfs ,$match_plf_name; recursion($match_plf_name); } } }

Replies are listed 'Best First'.
Re^5: Recursive search
by roboticus (Chancellor) on Dec 17, 2010 at 20:39 UTC

    perl mystery:

    You forgot perldoc chomp. Alternatively, you can remove the $ from your regex.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      I did try chomp as below,didnt make a difference?

      sub recursion { my $plf = shift; print "\nPLF in recursion:$plf\n"; open my $fh, '<', $plf or die "could not open '$plf' $!"; chomp $fh; foreach (my $line = <$fh>) { chomp $line; print "LINE:$line"; if($line =~ /\/(.+?\.plf)/) { print "LINE CONDITION:$line"; #print $1; $match_plf_name = $1; next if $match_plf_name eq $plf; push @recursive_plfs ,$match_plf_name; recursion($match_plf_name); } } }

        try

        while (my $line = <$fh>) # not foreach
        poj