in reply to finding and replacing

my @a = qw(dave brian alex's eddie's); s/'/\\'/ for @a; print qq($a[3]\n); --Output -- eddie\'s

     You're just jealous cause the voices are only talking to me.

     No trees were killed in the sending of this message.    However, a large number of electrons were terribly inconvenienced.

Replies are listed 'Best First'.
Re^2: finding and replacing
by perlbeginner10 (Acolyte) on Dec 04, 2005 at 19:07 UTC
    Hi, In my case, this works for only the first " ' ", not all. If there are two or more " ' ", the program doesn't work. Can anyone explain why?
      You need to post your code for us to be able to help you.

      Simply saying it does not do what you expect does not help - we need to know what "it" is before we can help.

      Update: - I'm guessing what you mean is that if a particular array element contains more than one single-quote, only the first single-quote gets escaped/replaced, in the code I posted.

      This is correct. If you need all of them replaced, use the "g" option in the regular expression .

      s/'/\\'/g for @a;

           You're just jealous cause the voices are only talking to me.

           No trees were killed in the sending of this message.    However, a large number of electrons were terribly inconvenienced.