Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

(atl) RE: Inserting stuff into a filehandle.

by atl (Pilgrim)
on Aug 09, 2000 at 14:53 UTC ( [id://27005]=note: print w/replies, xml ) Need Help??


in reply to Inserting stuff into a filehandle.

That might depend on the operating system (at least I think that some old OSes with structured files types could behave totally different from Unix/Win).

General remark: it is good idea to state the OS and Perl version (including used modules) if you ask a question.

If you are using some sort of Unix, the answer is: no. You can seek any position inside the file, but if you write, you overwrite.

Now, the question is, what do you want to do? If you generate some output (say, dynamic HTML) you might just buffer it into variables and write it out in one go. If your intermediate results have to be persistent (i.e. written to disk), you might consider storing them in seperate files and build your final file as needed. (Might be a good idea anyway, 'cause you don't manipulate earlier results which makes debugging easier.) If that is no option, too, I'm afraid you got to go with the tmp-file solution proposed by the other monks.

Hope that helps a bit ...

Andreas

UPDATE:Merlyn pointed to the faq section on this topic when answering a similar question. I looked it up and there is a description on how to do it with temporary files: look here. Aaah, resourceful monastry ;-))

  • Comment on (atl) RE: Inserting stuff into a filehandle.

Replies are listed 'Best First'.
RE: (atl) RE: Inserting stuff into a filehandle.
by Punto (Scribe) on Aug 09, 2000 at 20:06 UTC
    I'm using linux, with perl 5.0
    I don't want to insert lines into a _file_, but into the filehandle. I'm getting data from STDIN, and I want to insert some data at the begginig before sending it to a MIME::Parser object. MIME::Parser takes the filehandle as a parameter.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://27005]
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: (6)
As of 2024-04-23 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found