• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

Pattern matching in Perl

I am intnterested in processing files that match the form

wgdisb_s_*.zip           or     wgdisb_m_*.zip

please help me contruct the pattern match in Perl.

This is what I have coded
if (($name =~ /wgdisb_m_*.zip/) ||                      
           ($name =~ /wgdisb_s_*.zip/)) {                      
           print "name of file to get $name\n";  
        }    

does not seem to work, please help new to pattern matching.

Thanks! Thanks! Many Thanks! in advance.
0
dbruk
Asked:
dbruk
1 Solution
 
bennycCommented:
if ($name =~ /wgdisb_(s|m)_.*\.zip/) {
  print "Filename = $name\n";
}

replace .* to +* if it's matching 1 or more.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now