ddrew78 has asked for the wisdom of the Perl Monks concerning the following question:
I need all of it to be on one line, with a space in between and some additional text, so I wrote this:1.1.1.1 2.2.2.2 3.3.3.3
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: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);
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.system "sed 's/ )/)/' sesip3 > sesip2";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: why does 'sed' remove the entire line?
by JavaFan (Canon) on Jun 10, 2010 at 15:51 UTC | |
by ddrew78 (Beadle) on Jun 10, 2010 at 16:03 UTC | |
Re: why does 'sed' remove the entire line?
by jettero (Monsignor) on Jun 10, 2010 at 15:42 UTC | |
Re: why does 'sed' remove the entire line?
by ambrus (Abbot) on Jun 11, 2010 at 21:46 UTC | |
Re: why does 'sed' remove the entire line?
by Generoso (Prior) on Jun 10, 2010 at 15:52 UTC | |
by ddrew78 (Beadle) on Jun 10, 2010 at 16:07 UTC |