Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Problem with deleting the first n characters on a line

by Cubes (Pilgrim)
on Jul 18, 2001 at 18:13 UTC ( [id://97665]=note: print w/replies, xml ) Need Help??


in reply to Problem with deleting the first n characters on a line

You're not resetting your file position before writing back into FOUND (and even if you did, I don't think this code would do what you expect because the new string you write out is shorter than the original).

The quick 'n' easy way: open up a second file for output. Loop through the entire input file, changing lines as necessary before printing them to the output file. At the end, remove the original and rename your output file to the original's filename.

  • Comment on Re: Problem with deleting the first n characters on a line

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-09-10 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (9 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.