use FileHandle; my $fh = new FileHandle; my @input_file2; tie @input_file2, 'Tie::File', \$fh, or die "Problem tying file $input +_file2: $!";

... gives...

usage: tie @array, Tie::File, filename, [option => value]... at ./SS7M +erge line 42

What's all that stuff with $fh? You appear to be trying to pass Tie::File a reference to a reference to (sic) a GLOB when all it really wants is a filename.

Surely you just meant...

tie my @input_file2, 'Tie::File', $input_file2 or die "Problem tying file $input_file2: $!";

You can pass 'Tie::File' a filehandle (aka a reference to a GLOB not a reference to a reference to a GLOB) but you'd need open it first.

open my $fh, '+<', $input_file2 or die "Problem opening file $input_file2: $!"; tie my @input_file2, 'Tie::File', $fh or die "Problem tying file $input_file2: $!";

Note, the FileHandle module was long ago superceeded by the IO::* modules (particularly IO::File and IO::Handle) but you rarely need to construct them explicitly.


In reply to Re^5: Merging specific data from 2 files into a third. by nobull
in thread Merging specific data from 2 files into a third. by sheasbys

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.