This one has me stumped. I'm starting with a file that looks something like this:
1.1.1.1 2.2.2.2 3.3.3.3
I need all of it to be on one line, with a space in between and some additional text, so I wrote this:
open(SESIP2, ">sesip2"); open(MYINPUTFILE, "sesip1"); while (<MYINPUTFILE>) { my($line) = $_; chomp($line); print SESIP2 "$line "; } close(MYINPUTFILE); close(SESIP2); open(SESIP3, ">sesip3"); open(MYINPUTFILE, "sesip2"); while (<MYINPUTFILE>) { my($line) = $_; print SESIP3 "dest \($line\)"; } close(MYINPUTFILE); close(SESIP3);
This gives me this: dest (1.1.1.1 2.2.2.2 3.3.3.3 ) So far so good. Now, I need to delete the space before ")", so i tried this simple one-liner:
system "sed 's/ )/)/' sesip3 > sesip2";
For some reason, this deletes the entire line, not just the space. Any ideas? I should probably mention that the IP addresses are stdin that get asked of the user earlier on. Everything else works like a charm, I just can't seem to get rid of that one space.

In reply to why does 'sed' remove the entire line? by ddrew78

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.