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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |