in reply to Re: add double quotes to a perl variable
in thread add double quotes to a perl variable

Consider also B::perlstring(), which not only handles escaping, but also adds the quote characters...

#!/usr/bin/perl -l use B; while (<>) { chomp; print B::perlstring($_) if /^[\$\w]+$/; }

The B module is bundled with Perl itself, so you already have it. The perlstring() function was added in Perl 5.8, so this will not work on Perl 5.6.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name