[Koha-devel] Perl syntax for strings
Thomas Klausner
domm at plix.at
Tue Jun 15 11:00:38 CEST 2021
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
--
#!/usr/bin/perl https://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
More information about the Koha-devel
mailing list