Re: [MacPerl-AnyPerl] singlesqoutes <-> doubleqoutes
[email protected] (allan) Fri, 20 Jul 2001 22:36:36 +0200
| Newsgroups | perl.macperl.anyperl |
|---|---|
| Message-ID | <[email protected]> |
but of course :-) thanks allan Ronald J Kimball wrote: > > 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