[Moscow.pm] String *may* require interpolation See page 51 of PBP. (Severity: 1)

Anton Nikishaev me на lelf.lu
Вс Окт 13 04:07:28 PDT 2013


On Oct 13, 2013, at 3:25 AM, Nikolay Mishin <mi at ya.ru> wrote:

> MoscowPM, доброй ночи,
>  
> почему файл с содержанием
>  
> my %hash={'test$test' => 1};
>  
> не проходит
>  
> perlcritic --single-policy=RequireInterpolation t_crit.pl
> выдавая
>  
> String *may* require interpolation at line 1, column 11.  See page 51 of PBP.  (Severity: 1)
> получается, что такую полиси нужно всегда отключать? зачем она тогда была придумана?

Высосали из.
PerlCritic со списками правил по умолчанию — бесполезен.

И на “page 51 of PBP” ссылаться немного странно, ибо там

    Use interpolating string delimiters only for strings that actually
    interpolate.

    Unexpectedly interpolating a variable in a character string is a
    common source of errors in Perl programs. So is unexpected
    non-interpolation. Fortunately, Perl provides two distinct types
    of strings that make it easy to specify exactly what you want.

    If you’re creating a literal character string and you definitely
    intend to interpolate one or more variables into it, use a
    double-quoted string:

	my $spam_name = "$title $first_name $surname";
	my $pay_rate  = "$minimal for maximal work";

    If you’re creating a literal character string and not intending to
    interpolate any variables into it, use a single-quoted string:

	 my $spam_name = 'Dr Lawrence Mwalle';
	 my $pay_rate  = '$minimal for maximal work';



-- 
lelf



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.pm.org/pipermail/moscow-pm/attachments/20131013/ca174dba/attachment.bin>


Подробная информация о списке рассылки Moscow-pm