http://www.perlmonks.org?node_id=826427

mikelieman has asked for the wisdom of the Perl Monks concerning the following question: (strings)

I just came across this while doing some maintenance work.
$debug = q{};
And can't think of a single reason why this would be preferable to the simpler form:
$debug = '';
Am I missing something here, or is it just another example of TMTOWTDI ( but you probably shouldn't... )

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: To express a null string, why would anyone use ...=q{} intead of ...= '' ?
by toolic (Bishop) on Mar 03, 2010 at 16:02 UTC
    Damian Conway, in his book Perl Best Practices, considers it a better practice to use q{} (the single-quote operator with matching braces) instead of two single quotes because two single quotes is easily confused with a double quote for some font settings.
Re: To express a null string, why would anyone use ...=q{} intead of ...= '' ?
by JavaFan (Canon) on Mar 04, 2010 at 09:56 UTC
    Here's a reason: (hey, you said you couldn't think of a single reason...)
    my $quote = q{'}; my $question = q{?}; my $star = q{*}; my $empty = q{};