Hi Bob,

    Thanks for a good reply, see my coments under your questions.
----- Original Message -----
From: Bob Showalter <[EMAIL PROTECTED]>
Date: Wednesday, December 3, 2003 9:54 am
Subject: RE: Reading files

> [EMAIL PROTECTED] wrote:
> > Hello All,
> > I am trying to open a file once , and then duplicate it's
> > File Handle. I am trying to workout example straight from
> > FAQ5, with no luck. 
> 
> What does "no luck" mean? You never tell us what happens when you 
> run your
> code.

When I run my code, I can't read form the duped handle I have created.
> 
> > I will basicly trying to open a file, dup
> > off a few handles and spread them across other processes. 
> 
> Huh? What are you trying to do?

I have very large files, size ranges from 10-25 GB per file. I need to process them. I 
am trying to spawn off threads and each thread will get its own file handle, with a 
position { I plan on using seek to move the position of each handle }

> 
> > Here is the
> > code 
> > 
> > #!/usr/bin/perl -w
> 
> always 'use strict', as others have said.

good point, but this is a test code I wrote on fly.
> 
> > 
> > $file="./text";
> > $|=1;
> > use Fcntl;
> > use IO::Handle;
> > 
> > $D_LOG = $ENV{MHCONTEXTFD};
> 
> What is this supposed to be?

This ws take'n out of FAQ5 example " how can I dup file handles "
> 
> > 
> > open($LOG, "< logfile");
> > open($D_LOG, "<& LOG");
> 
> Check for errors!
> 
> > $LOG->autoflush(1);
> > $D_LOG->autoflush(1);
> 
> Why are you autoflushing handles opened for read? Does nothing.

That is true, I used this code where I was writing to files.
> 
> > 
> > $line1=<$LOG>;
> > $line2=<$D_LOG>;
> > 
> > print "1:$line1 2:$line2";
> > 
> 
> I think this approach is doomed to failure, do to the stdio 
> buffers not
> being shared.

Possibly, I have used sysread with no luck as well.

> 
> Why do you feel you need to dup the input handle? What's the 
> problem are you
> trying to solve?

Basicly as I said I need to process large files. I will write a multi threaded app and 
I dont want each thread to open a file. I'll have the main thread open a file once, 
and dup out handles which it will then distribute to the threads. each thread will get 
it's own small peace of file to work on, which should make processing these jobs alot 
faster. 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to