Hi all,
Long story short I'm trying to compare two HTML files for differences. I already have a program that strips the HTML and puts each word on its own line, I'm happy with this. The output is two new files that I then want to compare differences between.
I now want a second program that does the comparing. I go ahead and open both files and save them to a new array:
open FILE1, $ARGV[0] or die "Couldn't open file: $!"; my @lines1 = <FILE1>; close(FILE1);
Same for a second file. I then try to compare them line-by-line using a foreach loop on the first same file. The exact code I use for the comparison is if($lines1[$_] eq $lines2[$_]). However I get the error:
Argument "line example here" isn't numeric in array element at compare.pl line 14.This confuses me, because I can access them exactly the same way outside the array, $lines[0] etc. Is there something obvious I'm missing? I'm fairly new to Perl so always happy to learn some theory behind the code. Thanks
In reply to File to array and reading back by Kris0r
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |