in reply to error message txtFile comparison with output in another txtfile

Global symbol "..." requires explicit package name is telling you that ... is undefined. For $gen that is because it should be @gen. For the others you need a

my ...;

in each case.

use List::Compare; use strict; open (GEN, "general.txt")||die("general.txt File cannot open\n"); open (SEA, "search.txt")||die("search.txt File cannot open\n"); my @gen=<GEN>; my @sea=<SEA>; my @result; my @final; for $a (@gen) { @result = grep/^\Q$a\E$/, @sea; push (@final , @result); } open(OUT, ">textCompare3Output.txt")||die("cannot create\n"); print OUT "\nSearch string that matches against general data:\t@final" +;

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: error message txtFile comparison with output in another txtfile
by juergenkemeter (Novice) on Jul 14, 2005 at 22:32 UTC
    Thanks, but there is (still) no output in the new produced textfile (see also my upper message) although 'general.txt' and 'search.txt' have both the same content. Jurgen

      You should provide sample data (file contents) in a <readmore>...</readmore> block in your original post so that others can reproduce your problem.


      Perl is Huffman encoded by design.
        Here is the content of the files to be compared: 'general.txt': 'search.txt':

      and now that the "compile" errors are fixed you should state your new problem: what do you expect to see and what do you actually see.

      For test purposes it would be better to print to STDOUT rather than to a file.


      Perl is Huffman encoded by design.
        well the code should take the search strings from 'search.txt' (here: 'Juergen'), take this string and compare it to all entries in 'general.txt'. Since one of the entries in 'general.txt' is a matching string, the output should be written into an output text file.