http://qs321.pair.com?node_id=583374


in reply to Re^4: Merging specific data from 2 files into a third.
in thread Merging specific data from 2 files into a third.

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.