Re: [MacPerl-AnyPerl] singlesqoutes <-> doubleqoutes
[email protected] (Ronald J Kimball) Fri, 20 Jul 2001 16:15:28 -0400
| Newsgroups | perl.macperl.anyperl |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jul 20, 2001 at 10:08:13PM +0200, allan wrote: > i know theres more than one way to do it, but i would like a cleaner way. > im trying to globally replace singlesqoutes with doubleqoutes and vice > versa and the script below does seem to work but its rather an akward > way to do it. is there a solution to do this without using those kinds > of placeholders? > $str =~ s/'/some_temp_for_singles/g; > $str =~ s/\"/some_temp_for_doubles/g; > $str =~ s/some_temp_for_singles/"/g; > $str =~ s/some_temp_for_doubles/'/g; > print "OK: ", $str; Use the translation operator, which does character-to-character translations: $str =~ tr/'"/"'/; Ronald