- It seems to me it's not inserting at all. Rather, it replaces.
- You should be using binmode on the handles.
- 1024 is a tiny buffer. I'd use sysread and 64*1024.
- @ARGV is used throughout instead of naming the arguments.
- Globals are needlessly used for the file handles.
Regarding the first point, if you were actually interested in tool that can both insert and replace, I would suggest
cp_range in_file out_file [ in_spec [out_spec] ]
in_spec: [in_start],[in_length]
in_start defaults to 0
in_length defaults to -1 (rest of file)
out_spec: [out_start],[in_length]
out_start defaults to end of file
out_length defaults to -1 (rest of file)
Negative values for *_start and *_length behave as per substr.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.