in reply to Script to compare 2 folders, including sub folders and files with content

Hi karthik.raju,

Have a look at the "matches" option in File::DirCompare. For example, adding this option to your script works for me: matches => sub { print "File contents $_[0] and $_[1] are identical.\n" }

By the way, as the File::DirCompare documentation mentions, your script is essentially doing the same thing as diff: diff --recursive --brief --report-identical-files (or diff -rqs)

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: Script to compare 2 folders, including sub folders and files with content
by karthik.raju (Acolyte) on Jul 04, 2016 at 07:19 UTC
    Hi Hauke, Thanks for your reply and i've tried with your answer

     matches => sub { print "File contents $_[0] and $_[1] are identical.\n" }
    but since i'm new to Subroutines so cant able to fit this in right place.

    since i'm getting error like "Not a subroutine: 'matches'".
    Can please give the correct place that where and how i need to call this.

      Hi karthik.raju,

      I suggest you re-read the documentation of File::DirCompare closely, as it gives examples of the correct syntax with which to supply options: they are supplied as a hash reference ({ matches => ... }) as the last argument to the compare function. If you still have trouble please see How do I post a question effectively? and show the exact error messages and the code needed to reproduce them.

      Regards,
      -- Hauke D