> -----Original Message----- > From: Vladimir Lemberg [mailto:[EMAIL PROTECTED] > Sent: Monday, February 12, 2007 12:33 > To: beginners@perl.org > Subject: pattern match > > Hi, > > I have a script, which suppose to find all *.xml files under > the specified directory then process them. > I'm facing the pattern match problem: > > use strict; > use warnings; > use Win32; > use File::Find; > > @ARGV = Win32::GetCwd() unless @ARGV; > > > my @dirs; > > find (\&FindXml, $ARGV[0]); > > sub FindXml > { > return if !stat || -d; > ( my $xml_file = $File::Find::name ) =~ /^.+\.xml$/; > push ( @dirs, $xml_file );
Then only get the files you want by: return if $File::Find::name !~ /^.+\.xml$/; push ( @dirs, $File::Find::name ); and push the $File::Find::name Wags ;) > } > > In this examples the pattern match /^.+\.xml$/ is not working > and all files regardless of the extension have been assigned > to $xml_file variable. > > ################# > > However, if I change parenthesis to count the matching, the > pattern seems to work. > > sub FindXml > { > return if !stat || -d; > my $xml_file = ( $File::Find::name =~ /^.+\.xml$/ ); > print $xml_file; > } > > I'll be really grateful for any help here. > > Thanks in advance, > Vladimir > > > > ********************************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. ********************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/