Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by sheasbys (Initiate)
on Nov 10, 2006 at 17:46 UTC ( [id://583370]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-26 01:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found