On Fri, 13 May 2016 00:11:57 -0400
Uri Guttman <u...@stemsystems.com> wrote:

> i stick to using fat comma ( => ) only for key/value pairs. it has
> the side effect of quoting a bareword to the left which makes those
> pairs easier to read. so i never use it just for a comma though i
> have seen it used like that. this is definitely a matter of taste and
> i know mine is better than most! :)
> 
> as for q{} i stick to using it when there are quote chars in the
> string. i haven't had trouble reading '' (vs "" vs q{}) as the null
> string. pick a better font if you have trouble! :) also context (not
> perl but code in general) should make it easier to know when a null
> string is being used.

Another method is to use `constant` since it creates constant subs
which perl replaces with the literal.

$ cat quotes.pl 
#!/usr/bin/env perl

use constant {
    qSPACE    => q{ },
    qCOMMA    => q{,},
    qQUESTION => q{?},
};

my $holders = join qCOMMA, (qQUESTION) x @cgi_params;

$ perl -MO=Deparse ./quotes.pl 
use constant ({'qSPACE', ' ', 'qCOMMA', ',', 'qQUESTION', '?'});
my $holders = join(',', ('?') x @cgi_params);
./quotes.pl syntax OK


Notice in the join that qCOMMA and qQUESTION were replaced with the
literal.


-- 
Don't stop where the ink does.
        Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to