Pattern matching in Perl

Posted on 2004-11-04
Last Modified: 2010-04-17
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.
Question by:dbruk
    1 Comment
    LVL 1

    Accepted Solution

    if ($name =~ /wgdisb_(s|m)_.*\.zip/) {
      print "Filename = $name\n";

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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Problem to adjust sheet 1 79
    zeroFront challenge 7 58
    for loop with Set 4 38
    drawing animated level bar based on numbers 3 47
    This article will show, step by step, how to integrate R code into a R Sweave document
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now