[Melbourne-pm] Bareword found where operator expected

Gary Smith gary at devgurus.com
Sun Feb 16 16:40:34 PST 2014

Hi All,

I'm seeing an error in a file here but I think it may be related to the 
development environment rather than the file. The reason I say that is 
because the error only occurs in the environment that I have created 
(with perlbrew) for myself. The production environment doesn't exhibit 
the same error and I also use this same code on a Debian VM without issue.

Perl version is 5.16.3

The environment is Catalyst/Pg/Starman.

Here is the error output:

Bareword found where operator expected at 
/home/gary/myapp/lib/myapp/Controller/Lookup.pm line 59, near "/^ \s* ( 
[\s\d\w]{3,} ) \s* $/ux"
         (Missing operator before ux?)
Error while loading /home/gary/myapp/myapp.psgi: syntax error at 
/home/gary/myapp/lib/myapp/Controller/Lookup.pm line 59, near "/^ \s* ( 
[\s\d\w]{3,} ) \s* $/ux"
Can't use global $1 in "my" at 
/home/gary/myapp/lib/myapp/Controller/Lookup.pm line 60, near "= $1"
BEGIN not safe after errors--compilation aborted at 
/home/gary/myapp/lib/myapp/Controller/Lookup.pm line 73.
Compilation failed in require at 
/home/gary/perl5/lib/perl5/Catalyst/Utils.pm line 308.
Compilation failed in require at /home/gary/myapp/myapp.psgi line 4.
BEGIN failed--compilation aborted at /home/gary/myapp/myapp.psgi line 4.

Here is the relevant code lines 59 & 60 in Lookup.pm:

         if ($c->request->params->{$field} =~ /^ \s* ( [\s\d\w]{3,} ) 
\s* $/ux) {
             my $value = $1;

I know that the code is fine as it has been working fine for many months 
and still works fine on the production and Debian servers. I don't know 
what in my environment would cause the error. It appears to be saying 
that it doesn't like the regex, but there doesn't appear to be any 
syntax issues there.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20140217/9fa7b994/attachment.html>

More information about the Melbourne-pm mailing list