use strict; my $test = "this is 'inquotes' o'leary"; $test =~ s/ \'(\S*)\' / \"$1\" /g; print "$test\n";