D. Bolliger am Montag, 12. Februar 2007 23:03: > Mumia W. am Montag, 12. Februar 2007 21:53: > > On 02/12/2007 02:33 PM, Vladimir Lemberg wrote: [snipped]
Mumia, please excuse me for my inappropriate correction! > > You probably want to push the filename onto the array if you get a > > successful match: > > > > sub FindXml > > { > > return if !stat || -d; > > ( my $xml_file = $File::Find::name ) =~ /^(.+\.xml)$/; > > push ( @dirs, $xml_file ) if $1; > > } > > [snipped] > > Mumia, > > This will not behave as expected because a test is missing if the match was > successful. I mention it mainly because it's a common error that is not > easy to detect at first glance :-) The following test script does *not* demonstrate any issue, because FindXml is called anew for every filename, while the script below uses the match in a loop. Sorry again, Dani > Test script demonstrating the issue: > > #!/usr/bin/perl > > use strict; > use warnings; > > my $pat='a'; > > for (qw/ a b c d/) { > (my $x=$_)=~/(^$pat$)/; > print "Found $pat in /$_\n" if $1; > } > > __END__ > > # Output is: > Found a in a > Found a in b > Found a in c > Found a in d -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/