singlesqoutes <-> doubleqoutes
[email protected] (allan) Fri, 20 Jul 2001 22:08:13 +0200
| Newsgroups | perl.macperl.anyperl |
|---|---|
| Message-ID | <[email protected]> |
hello list 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? thanks allan #!/usr/bin/perl -w my $str = qq(this word should have 'doubleqoutes' and this should have "singleqoutes"); $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; #this approach would not be OK: #$str =~ s/'/"/g; #$str =~ s/"/'/g;