in reply to Re^7: Recursive search
in thread Recursive search
Thanks,that worked.My below regex is failing for "script_rev1.1.plf",is it because \w is alphanumberic and doesnt match a "."(dot),can u pls suggest how to change the regex to match this awell
2. After pushing the "$match_plf_name" to "@recursive_plfs,when I try to print it,I only see the first element pushed getting printed,why only one element is getting stored in the array?if($line =~ /\/$(\w+\.plf)/)
foreach my $plf (@plf_files) { #print $plf; if (grep (/\Q$plf\E/i,@file)) { push @recursive_plfs,$plf; recursion($plf); } } sub recursion { my $plf = shift; #print "\nPLF in recursion:$plf\n"; open my $fh, '<', $plf or die "could not open '$plf' $!"; while (my $line = <$fh>) { chomp $line; #print "\nLINE:$line"; if($line =~ /\/(\w+\.plf)/) { #print "LINE CONDITION:$line"; $match_plf_name = $1; print "MATCH PLF:$match_plf_name\n"; next if $match_plf_name eq $plf; next if ( not grep { /\Q$match_plf_name\E/i } @plf_fil +es); print "IN"; push @recursive_plfs,$match_plf_name; recursion($match_plf_name); } } } foreach my $matchplf (@recursive_plfs) { print $matchplf; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Recursive search
by perl_mystery (Beadle) on Dec 17, 2010 at 22:17 UTC | |
by poj (Abbot) on Dec 17, 2010 at 22:42 UTC | |
by perl_mystery (Beadle) on Dec 17, 2010 at 22:51 UTC | |
by poj (Abbot) on Dec 17, 2010 at 23:02 UTC | |
by Anonyrnous Monk (Hermit) on Dec 17, 2010 at 23:18 UTC | |
by perl_mystery (Beadle) on Dec 17, 2010 at 23:49 UTC | |
|