[Koha-devel] Perl syntax for strings
Fridolin SOMERS
fridolin.somers at biblibre.com
Wed Jun 16 17:17:52 CEST 2021
OK so proposing to remove this space makes sens, great ;)
Also looks like Perl::Tidy does not remove the space.
Le 15/06/2021 à 11:00, Thomas Klausner a écrit :
> Hi!
>
> On Tue, Jun 15, 2021 at 10:19:12AM +0200, Fridolin SOMERS wrote:
>
>> I see in Perl code some cases where a string in written with a space between
>> q or qq or qw and string.
>> Like : qq /foo bar/ instead of qq/foo bar/
>
> While this works, it is strongly recommended to not use this "feature".
> It's main "use" is to use ANY string as quote-like operator:
>
> perl -E 'say qq A({/";A'
> ({/";
>
> But of course this is horrible and should not be used (outside of
> obfuscations..)
>
>> Most of cases are in :
>> use CGI qw ( -utf8 );
>
> This isn't even using the "feature" to allow any string..
>
>> There are only 29 other cases :
>> git grep -E ' q[qw]? [/({]' | grep -v 'use CGI qw '
>
> Of course this regex would fail to find why the space after q/qq/qw is
> allowed, because using the space you can use ANY char for the quote-like
> op. But I'm quite sure that nobody is crazy enough to put that into
> production code. And coming up with a regex that matches this would be
> quite hard... Though maybe there is a Perl::Critic rule for it?
>
>> Should we add a coding guideline ?
>> https://wiki.koha-community.org/wiki/Coding_Guidelines
>
> ++
>
> Greetings,
> domm
>
--
Fridolin SOMERS <fridolin.somers at biblibre.com>
Software and system maintainer 🦄
BibLibre, France
More information about the Koha-devel
mailing list