in reply to Converting double quoted string to single quoted string
Regexp::Common has a mechanism that simplifies this greatly.
#! /usr/bin/perl use strict ; use warnings ; $|++ ; use Regexp::Common qw( delimited ) ; my $str = do { local $/; <DATA> } ; print "\nBefore\n-----\n", $str ; $str =~ s/$RE{delimited}{-delim=>'"'}{-keep}/'$3'/gs ; print "\nAfter\n-----\n", $str ; exit ; __DATA__ "Welcome to my humble abode," I said, spreading my arms. "You mean, you live here? In the monastery?" "Absolutely. Come, I'll show you about. Everything you need is located right here, from tutorials to friendly advice."
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
|
|---|