Dear Perl Monks: I am trying to write a script to do the following: 1. Read a list of files into an array from a file 2. Compare each file in the array to one another using cmp 3. Print the results to a file. This is my attempt so far... #!/usr/bin/perl -w #open file open(OUTFILE, ">/media/hda3/differences.txt") or die("Unable to open f +ile"); #read file into array @data = <FILE>; #close file close (FILE); #Used to test if data is read into array #print $data[2]; #open file to save differences open(FILE, "/media/hda3/differences.txt"); #loop to determine differences for ($i=0; $i<377; $i++) { for($j=$i+1; $j<377; $j++) { $command_line = "cmp -l /media/hda3/2967test/"$data[$i]" /media/h +da3/2967test/"$data[$j]"| wc -l"; $diff_count = system $command_line; print OUTFILE ($data[$i], "\t", $date[$j], "\t", $diff_count, "\n +"); } } #close file close(FILE); These are the error msgs that I receive Scalar found where operator expected at ./differ.pl line 23, near ""cm +p -l /media/hda3/2967test/"$data" (Missing operator before $data?) String found where operator expected at ./differ.pl line 23, near "]" +/media/hda3/2967test/"" (Missing operator before " /media/hda3/2967test/"?) Scalar found where operator expected at ./differ.pl line 23, near "" / +media/hda3/2967test/"$data" (Missing operator before $data?) String found where operator expected at ./differ.pl line 23, near "]"| + wc -l"" (Missing operator before "| wc -l"?) syntax error at ./differ.pl line 23, near ""cmp -l /media/hda3/2967tes +t/"$data" Execution of ./differ.pl aborted due to compilation errors. I am having a hard time debugging this. Any ideas what I am doin +g wrong here? Is there a better way to do this? Thank you for your +advice. Sincere Seeker of Perl Wisdom, Lunchb0x

In reply to Script to Find Differences Between Files by lunchb0x

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.