Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I would like to answer the underlying reason why editing the lines of text in-situ is not possible. Consider what the file actually is in terms of byte storage
0000000 # ! / u s r / l o c a l / b i +n 043 041 057 165 163 162 057 154 157 143 141 154 057 142 151 15 +6 0000020 / p e r l - w \n u s e s t +r 057 160 145 162 154 040 055 167 012 165 163 145 040 163 164 16 +2 0000040 i c t ; \n p r i n t " H e l +l 151 143 164 073 012 160 162 151 156 164 040 042 110 145 154 15 +4 0000060 o W o r l d \ n " ; \n 157 040 127 157 162 154 144 134 156 042 073 012 0000074
To change bytes in the middle may be possible, but to increase the length of lines would involve inserting bytes (hence shuffling the remainder forwards).

Also, this is just how text files are implemented on one operating system (Unix). Others may use different line terminators, or implement in a completely diferent way, such as VMS, which stores the text file as a series of variable length records. Anything which relies of the Unix representation will potentially be non-portable.


In reply to Re: Edit File in place by rinceWind
in thread Edit File in place by RollyGuy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found