On Mon, 3 Feb 2003, Paul Gear wrote:
paul POULAIN wrote:
Paul Gear a écrit:
Premature end of script headers: z3950servers.pl, referer: http://enoch.gear.dyndns.org:82/cgi-bin/koha/admin-home.pl Bareword "C4Connect" not allowed while "strict subs" in use at /opt/koha/intranet/cgi-bin/admin/z3950servers.pl line 176., referer: http://enoch.gear.dyndns.org:82/cgi-bin/koha/admin-home.pl Bareword "C4Connect" not allowed while "strict subs" in use at /opt/koha/intranet/cgi-bin/admin/z3950servers.pl line 245., referer: http://enoch.gear.dyndns.org:82/cgi-bin/koha/admin-home.pl * Changing the C4Connect bareword to &C4Connect in admin-home.pl fixed this.
Could some perl-geek explain this one ?
I'm half a perl geek... The syntax used is perl 4 (?) style and is no longer supported under 5.8.
(1) The &funcname syntax is supported in perl 5.8. I just checked the perldelta for 5.8 and in fact, the use of &funcname is exhibited several times. And for more proof: [chicks@chicks]$ perl -e 'sub x { print "hi\n"; } &x;' hi [chicks@chicks]$ perl -v This is perl, v5.8.0 built for i386-linux-thread-multi (2) the 'Bareword "C4Connect" not allowed while "strict subs"' error is explained as: Bareword "%s" not allowed while "strict subs" in use (F) With "strict subs" in use, a bareword is only allowed as a subroutine identifier, in curly brackets or to the left of the "=>" symbol. Putting the & in front or () behind the seeming barewood solves the problem generally. & is the more vintage way to do things and is necessary if perl4 compatibality is an issue. Putting () aftewards tends look more current. The difference between prepending & or appending () in this case is not merely aesthetic: $ perl -e 'sub doh { print "...@_...\n"; } sub bah { doh(); } bah( qw(x y z a b c));' ...... $ perl -e 'sub doh { print "...@_...\n"; } sub bah { doh; } bah( qw(x y z a b c));' ...... $ perl -e 'sub doh { print "...@_...\n"; } sub bah { &doh; } bah( qw(x y z a b c));' ...x y z a b c... The pre-& call to doh passes the arguments along, while the other two forms don't. Underlying this problem is that "C4Connect" isn't being pre-declared properly. (That's the other way this problem is avoided.) To show another one-liner: [chicks@chicks]$ perl -e 'sub lala { print "lala\n"; } lala;' lala So, even in perl 5.8 the bareword is recognized as a subroutine call if it's been pre-declared. [this sat in my outbox since yesterday. sorry.] -- </chris> "Never offend people with style when you can offend them with substance." - Sam Brown