|
|
Joined: Aug 2000
Posts: 226
Member
|
Member
Joined: Aug 2000
Posts: 226 |
Is there any way that I can easily over write the last 2 lines of a file in perl without having to rewrite the entire file?
Amy
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
Joined: Sep 2000
Posts: 755 |
If you're using fixed length records then you can seek to the appropriate spot. Otherwise you'll need to rewrite the file with the correct data.
Read in the old file, and output the new over the old, replacing the lines you need replaced
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: Aug 2000
Posts: 226
Member
|
Member
Joined: Aug 2000
Posts: 226 |
Thanks Mark, I was hoping to get around doing that, but I guess I'm stuck.
Amy
|
|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
Joined: Aug 2000
Posts: 335 |
I suppose you could also 'seek' to the end of the file, backup until you get to the third newline character, then write the two new lines. If the new lines are shorter than the old lines, you might have to 'truncate' to get rid of the extra text.
I don't know how efficient this is.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 449
Joined: February 2008
|
|
Forums63
Topics37,575
Posts293,932
Members13,824
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|