Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
go ahead... be a heretic
 
PerlMonks  

Re: error message txtFile comparison with output in another txtfile

by BaldPenguin (Friar)
on Jul 14, 2005 at 18:03 UTC ( [id://475066]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

You don't have a $gen declared only an array, @result and @final are not declared, try:
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 @final = (); for $a (@gen) { my @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" +;

Don
WHITEPAGES.COM | INC
Everything I've learned in life can be summed up in a small perl script!
  • Comment on Re: error message txtFile comparison with output in another txtfile
  • Download Code

Replies are listed 'Best First'.
Re^2: error message txtFile comparison with output in another txtfile
by Fang (Pilgrim) on Jul 14, 2005 at 18:12 UTC

    The variable in the foreach loop should also be properly declared, and preferably not called $a.

    for my $pattern (@gen) { my @result = grep/^\Q$pattern\E$/, @sea; push (@final , @result); }
Re^2: error message txtFile comparison with output in another txtfile
by juergenkemeter (Novice) on Jul 14, 2005 at 18:20 UTC
    the code has no errors now, but the comparison doesnt work properly, there is no output in the new textfile except 'Search string that matches against general data:' Even if I have two same entries in 'search.txt' and 'general.txt', there is still no output. Perhaps the @final variable does not work properly? Jurgen

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://475066]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.