Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

To express a null string, why would anyone use ...=q{} intead of ...= '' ?

by mikelieman (Friar)
on Mar 03, 2010 at 15:17 UTC ( [id://826427]=perlquestion: print w/replies, xml ) Need Help??

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{};

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://826427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-03-28 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found