Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: inserting a tag before a string

by Laurent_R (Canon)
on Nov 30, 2017 at 16:25 UTC ( [id://1204611]=note: print w/replies, xml ) Need Help??


in reply to Re^2: inserting a tag before a string
in thread inserting a tag before a string

I can not do insert before tag "</catalog>"
You don't provide enough information, so this is a shoot in the dark. Are you aware that it is not usually possible to directly modify the contents an ordinary sequential file (except appending new contents at the end). But there are some ways to work around that limitation.

One of the common ways to modify a file is to read it into memory, to modify the contents in memory, and to write back the modified contents into the file (i.e. clobbering the existing content). Usually, you would first rename the original file or use a temporary file for writing, and do the necessary house-cleaning afterwards, once you have confirmed that everything went well, just to make sure you don't accidentally delete your original data.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-03-28 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found