Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Seek in IPC::Open2 modules handle

by Samy_rio (Vicar)
on May 20, 2009 at 09:16 UTC ( [id://765150]=perlquestion: print w/replies, xml ) Need Help??

Samy_rio has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I am posting the the url and getting the response using IPC::Open2 modules. I am getting the output using $rdrfh handle.

I fetch some data from $rdrfh handle and again i need the data from the start position.

I tried seek funciton with the $rdrfh handle, but it's not working

use Fcntl qw(SEEK_SET); use IPC::Open2; ... open2($rdrfh, $wtrfh, 'some cmd and args'); ... seek($rdrfh, 0,0); #not working seek($rdrfh, 0,SEEK_SET); #not working

Is it possible to seek the IPC::Open2 module file handle? How?

Thanks in advance

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re: Seek in IPC::Open2 modules handle
by Corion (Patriarch) on May 20, 2009 at 09:17 UTC

    No - in general, pipes from other programs are not seekable.

    If you need a seekable file, have the generating program write to a temporary file and read from that temporary file.

Re: Seek in IPC::Open2 modules handle
by ikegami (Patriarch) on May 20, 2009 at 14:36 UTC
    If you liken the file handle contents to words, a file is like a book (you can seek through it) while a pipe is like an oral conversation. Unless you happen to record it, you can't rewind it. You definitely can't skip forward.

Log In?
Username:
Password:

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

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

    No recent polls found