Re: pie multiline replace

2008-06-07 Thread brian d foy
[[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article <[EMAIL PROTECTED]>, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > I think you are right. I'd suggest that you send a note to Brian d'Foy that's just brian d foy. No apostro

Re: pie multiline replace

2008-06-06 Thread Richard Lee
Gunnar Hjalmarsson wrote: close $out; I was just going over this... but shouldn't it be print $out "# Add this line to the top\n"; # ??? or did I miss something? I think you are right. I'd suggest that you send a note to Brian d'Foy ([EMAIL PROTECTED]), who is maintaining the FAQ.

Re: pie multiline replace

2008-06-06 Thread Gunnar Hjalmarsson
Richard Lee wrote: Gunnar Hjalmarsson wrote: perldoc -q "insert a line" Within that basic form, add the parts that you need to insert, change, or delete lines. To prepend lines to the beginning, print those lines before you enter the loop that prints the existing lines. open my $

Re: pie multiline replace

2008-06-05 Thread Richard Lee
Gunnar Hjalmarsson wrote: bill lam wrote: Sorry this must be a faq but I cannot find any answer in google. Google?? If you think it's a FAQ, you'd better check the Perl FAQ. perldoc -q "insert a line" Within that basic form, add the parts that you need to insert, change, or delete lines

Re: pie multiline replace

2008-06-05 Thread bill lam
Rob Dixon wrote: If you think the one-liner is non-trivial then all the more reason that you should use a proper script. It is a bad idea to use any code unless you understand why and how it works. The script isn't trivial (to me) either. Incidentally the same can be done in sed one-liner. se

Re: pie multiline replace

2008-06-05 Thread Rob Dixon
bill lam wrote: > Thomas Bätzler wrote: >> perl -i -ple '$_ = "cc\n$_" if $p =~ m/aa/ && m/bb/; $p=$_' > > Thanks. looks non-trivial for me. Anyway I will copy this idiom into my cheat > sheet. > > Thank Gunnar for suggestion too. However I prefer one-liner. If you think the one-liner is non-tr

Re: pie multiline replace

2008-06-05 Thread bill lam
Thomas Bätzler wrote: perl -i -ple '$_ = "cc\n$_" if $p =~ m/aa/ && m/bb/; $p=$_' Thanks. looks non-trivial for me. Anyway I will copy this idiom into my cheat sheet. Thank Gunnar for suggestion too. However I prefer one-liner. regard, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

Re: pie multiline replace

2008-06-05 Thread Gunnar Hjalmarsson
bill lam wrote: Sorry this must be a faq but I cannot find any answer in google. Google?? If you think it's a FAQ, you'd better check the Perl FAQ. perldoc -q "insert a line" Suppose I want to change 2 lines to 3 line in files as follow using perl -p -i -e command aa bb aa cc bb this

RE: pie multiline replace

2008-06-05 Thread Thomas Bätzler
bill lam <[EMAIL PROTECTED]> asked: > Suppose I want to change 2 lines to 3 line in files as follow > using perl -p -i -e command aa bb > > aa > cc > bb > > this doesn't work > perl -p -i -e "s/aa\nbb/aa\ncc\nbb/g;" foo.txt That won't work since you ever only see a single line of input. Since

pie multiline replace

2008-06-05 Thread bill lam
Hello, Sorry this must be a faq but I cannot find any answer in google. Suppose I want to change 2 lines to 3 line in files as follow using perl -p -i -e command aa bb aa cc bb this doesn't work perl -p -i -e "s/aa\nbb/aa\ncc\nbb/g;" foo.txt what is the correct command (I use linux). Thanks