in reply to Converting double quoted string to single quoted string
It might be worth pointing out that, given yout trivial example, $str contains identical information regardless of which form of quotes are used.
That is to say
$str1 = "Some String"; $str2 = 'Some String'; if( $str1 eq $str2 ) { print ">>$str1<< is identical to >>$str2<<\n"; }
Gives:
>>Some String<< is identical to >>Some String<<
So, without resorting to something esoteric like source filtering, the only way to change the quotes (in your example), is to do so manually with your editor!
So changing how the strings are quoted only becomes meaningful if the strings you are programmically changing contain embedded quotes. eg.
$str1 = "'Some String'"; $str2 = '"Some String"'; if( $str1 ne $str2 ) { print ">>$str1<< is different to >>$str2<<\n"; } ... >>'Some String' is different to >>"Some String"<<
Therefore, your question only really makes sense if the source of the contents of the strings is external to your program as DamnDirtyApe demonstrated.
Is this what you meant?
|
|---|