Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: Merging specific data from 2 files into a third.

by nobull (Friar)
on Nov 10, 2006 at 18:16 UTC ( [id://583374]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://583374]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-23 15:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found