Looking for files in Perl

Posted on 2012-08-13
Last Modified: 2012-10-05

Can anyone please help me with a code snippet for the below one:

Condition:  Read directories and sub-directories recursively  from a path and look for files "_ETS.xml", ".PDF", "_MERC.xml from each directory and output " Dirname | 1| 1" if available  else  "Dirname | 0 | 0 " if any thing is not available to a log file.

Question by:new_perl_user
    1 Comment
    LVL 84

    Accepted Solution

    # Assuming that Dirname is the name of a directory which contains
    # *_ETS.xml and *.PDF and *_MERC.xml"
    use File::Find;
    find( sub{ -d && print join(" | ",$File::Find::name,((()=<$_/*_ETS.xml>) && (()=<$_/*.PDF>) && (1-!(()=<$_/*_MERC.xml>)))x2),"\n"}, ".");

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    PHP equivalent of opening a com object 5 54
    Using Perl to parse rows 7 82
    iSeries PERL Scripts 7 117
    Perl string filter 5 45
    I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    730 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

    17 Experts available now in Live!

    Get 1:1 Help Now