in reply to Re^4: comparing contents of two arrays and output differences
in thread comparing contents of two arrays and output differences

Or you could use a subset of Text::Diff called Text::Diff::Table. Such that you print out the difference in a table like using diff -y text1 text2 in *ux OS, just like RichardK mentioned previously.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
  • Comment on Re^5: comparing contents of two arrays and output differences

Replies are listed 'Best First'.
Re^6: comparing contents of two arrays and output differences
by PitifulProgrammer (Acolyte) on Jan 05, 2015 at 13:54 UTC

    Dear 2Teez,

    I've been trying to solve my little programming problem using the module, however, due to my lack of experience, I somehow have not been able to run the comparison properly

    What I did not understand in the CPAN description was the fact that only one array is used for the comparison, e.g.

    diff \@a, $b { STYLE => "Table" };

    I would have expected to have two @arrays for comparision, e.g.

    my @xml_files = glob( '*xml' ); #say for @xml_files; my @bak_files = glob( '*bak' ); #say for @bak_files; #using the Text::Diff::Table for comparison my $format = ""; my @joint_files = @xml_files, @bak_files; my @results = diff \@joint_files, $format { STYLE => "Table" }; say for @results;

    However, I am getting the following error message, saying that the module is not install properly

    C:\dev>perl comparing_files_3_using_text_diff.pl ./file_compare_on_lis +ts Can't locate package Text::Diff::Base for @Text::Diff::Table::ISA at c +omparing_f iles_3_using_text_diff.pl line 4. Backslash found where operator expected at comparing_files_3_using_tex +t_diff.pl line 20, near "diff \" (Do you need to predeclare diff?) syntax error at comparing_files_3_using_text_diff.pl line 20, near "di +ff \" Global symbol "%format" requires explicit package name at comparing_fi +les_3_usin g_text_diff.pl line 20. Global symbol "@results" requires explicit package name at comparing_f +iles_3_using_text_diff.pl line 22.

    I suppose I have to use the module as is, but what does $b represent and why can't it be changed to $format?

    Could somebody give me a hint why I am getting the error message despite the module being installed?

    I am confused about these package name declaration, I thought I did everything by the book

    Thanks a mil in advance for your support

    Kind regards

    C.