Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Looking for files in Perl

Hi,

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.

Thanks,
0
new_perl_user
Asked:
new_perl_user
1 Solution
 
ozoCommented:
# 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"}, ".");
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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