If you're going to use seek, read the documentation, the first graf of which explains how to increment the position:
 seek FILEHANDLE,POSITION,WHENCE
        Sets FILEHANDLE's position, just like the "fseek" call of
        "stdio". FILEHANDLE may be an expression whose value gives the
        name of the filehandle. The values for WHENCE are 0 to set the
        new position *in bytes* to POSITION; 1 to set it to the current
        position plus POSITION; and 2 to set it to EOF plus POSITION,
        typically negative. For WHENCE you may use the constants
        "SEEK_SET", "SEEK_CUR", and "SEEK_END" (start of the file,
        current position, end of the file) from the Fcntl module.
        Returns 1 on success, false otherwise.

Assuming your really intend to do something like this:

#!/usr/bin/perl use 5.016; use Data::Dumper; #1033562 (and id num_qqq.txt, idnum_exp.txt) =head file 1033562_exp.txt exp.txt 0 foo 3 bar 1 table 3 quux 3 fail 2 file 1033562_qqq.txt qqq.txt 0 fail 2 nope 1 foo 3 insert 1 bar 1 quux 3 table 3 tambourine 2 fred 14 =cut open(INDB, "1033562_exp.txt") or die "Can't open exp file, $!"; open(QQQ, "1033562_qqq.txt") or die "Can't open data file, $!"; my (@search, @therecs); while(<INDB>) { my $search = $_; chomp($search); say "\$search at Ln28: $search"; push @search, $search; seek(INDB, 0, 0); } print "\n\n"; while(<QQQ>) { my ($ma,$id); my $therec = $_; say "Both elements of \$therec at Ln36: $therec"; chomp($therec); ($ma,$id ) = split(/\t/, $therec); push @therecs, (" $ma " . "| $id |"); my $Qpos=tell QQQ; say "\n\t POS in QQQ: $Qpos \n"; } say "\n \t array search next:"; say Dumper @search; say "\n \t Array @therecs next:"; say Dumper @therecs;
</c>

Identifying the matches is left as an exercise to the SOPW. %hash might be an approach; so too might what you originally suggest but didn't implement-- walking the arrays in parallel. Both are well documented in threads here in the Monastery.


If you didn't program your executable by toggling in binary, it wasn't really programming!


In reply to Re: Threading two text files by ww
in thread Threading two text files by ostra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.