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

Thank you liverpole. I was just reading about using "my" and your post confirmed this is what I ought to do. My useage of tie::file seems to be the only thing holding back this script now. The only error I now get is this:

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

Thanks again,
Stephen

Replies are listed 'Best First'.
Re^5: Merging specific data from 2 files into a third.
by nobull (Friar) on Nov 10, 2006 at 18:16 UTC
    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.