hi Mihir Kamdar,

Please the following highlighted.

 I have tested it. this  excatly  does what you need.

configure the parent_path,child_path and out_path to your corresponding
paths.

_____________________ BEGIN




use strict;
use File::Path;
use File::Copy;
use warnings;

my $parent_path="C:/parent";
my $child_path="C:/child";
my $out_path="C:/output";
my @parent_files=<$parent_path/*>;


#########  THIS SECTION ACTS AS the Touch Command Check the Files in Parent
Directory and Created the zero bye files in the Child directory#############

foreach my $file (@parent_files)
{
      my @arr=$file=~ /(\w+\.\w+)$/;
      if (-f "$child_path/$arr[0]" )
      {
      }
      else
      {

           open my $W_H, '>', "$child_path/$arr[0]" || die "Could not Create
the file $child_path/$arr[0]\n";
           close $W_H;
      }

}

######################################################################################################################################


############################## this section Checks the files in the child
directory, Takes the same file from the parent directory removes duplicates
from the file and creates the  file in  output directory
#####################################################################################3

my @child_files=<$child_path/*>;


foreach my $file (@child_files)
{
      my @arr=$file=~ /(\w+\.\w+)$/;
      my %uniques;
      open my $R_H, '<',  "$parent_path/$arr[0]";
      my @file_content=<$R_H>;
      close $R_H;
      foreach my $line (@file_content)  {  $uniques{$line}++; }
      open my $W_H, '>', "$out_path/$arr[0]";
      for(keys(%uniques)) { print $W_H "$_\n"; }
      close $W_H;
}

######################################################################################################################################


_________________________________ END

Regards,
Siva

Reply via email to