in reply to Re: Line by line parsing from one file, comparing line by line to another file
in thread Line by line parsing from one file, comparing line by line to another file

I atempted a modified version of your script and got this:
$ perl.exe perl2.pl
Global symbol "@data" requires explicit package name at perl2.pl line 27.
Can't find string terminator "|" anywhere before EOF at perl2.pl line 27.

#!/usr/bin/perl<br> use strict;<br> use warnings;<br> <br> # 777297<br> <br> my $data_file = "test1.txt";<br> open(DATA, $data_file) || die("Could not open file!");<br> my @data_file = &lt;DATA&gt;;<br> <br> my $names_file = "code.txt";<br> <br> open(NAMES, $names_file || die "Could not open file!");<br> my @names_data = &lt;NAMES&gt;;<br> <br> # create loop that reads each ID in code.txt (NAMES array), searches f +<br> #+or each in array elements for #test1.txt<br> # (DATA array), redirects a new (NAMES).html for each element<br> <br> my ($names, $data);<br> for $names(@names_data) {<br> &nbsp;&nbsp;&nbsp; chomp($names);<br> &nbsp;&nbsp;&nbsp; for $data(@data_file) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chomp ($data);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($data =~ /$names/) {<br +> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "found \$names ( $names )&nbsp; in \$data \n";<br> push @data, qq | &gt; $names.html "\n";<br> &nbsp;}<br> &nbsp;&nbsp;&nbsp; }<br> }<br> <br> close NAMES;<br> close DATA;
  • Comment on Re^2: Line by line parsing from one file, comparing line by line to another file
  • Download Code

Replies are listed 'Best First'.
Re^3: Line by line parsing from one file, comparing line by line to another file
by ww (Archbishop) on Jul 05, 2009 at 11:25 UTC

    The message you cite is about push @data, qq | > $names.html "\n"; is about the missing closing delimiter ( "|" ) for qq (your lack of code tags forced me to count. Meh!) But that's not the whole problem by a long shot.

    If you really want to learn Perl, "cargo-culting" (which is what you appear to be doing) is a poor course of instruction. Instead, suggest you start working your way through Learning Perl; the Tutorials here; from http://www.perltraining.com.au or from any one of several very good introductory courses available on-line (your pick, but those from colleges and universites, .edu, are sometimes better than the [very low] average web site).

      Thank you.