You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Tom Robinson <to...@motec.com.au> on 2014/06/13 04:27:25 UTC

Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/... //r"

Hi,

Sorry to bother you with this. As referenced on the ApacheSpamAssassin Wiki for AutoWhiteList
(https://wiki.apache.org/spamassassin/AutoWhitelist) I downloaded the Truxoft version of the
sa-heatu utility (http://truxoft.com/resources/sa-heatu.v4.02.tar.gz ) but when I run it I get these
errors:

Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/... //r"
Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/:.. / /r"
syntax error at /usr/local/bin/sa-heatu line 227, near "s/... //r "
Execution of /usr/local/bin/sa-heatu aborted due to compilation errors.

I'm running a CentOS 5.10, 32bit system.

My version of perl is:
# perl -version
This is perl, v5.8.8 built for i386-linux-thread-multi
---8<---snip*---

I fetched a version of sa-heatu from git hub as well but it is the same file (diff shows no
differences and I get the same errors when running).

Here is a snippet of the code in context:

224     if ($count && ($opt_verbose || ($opt_verboseHits && $count>$opt_verboseHits) ||
($opt_showUpdates && $prtu))) {
225         printf $fmt, $totscore/$count, $totscore,$count, $email, $ip, $reason;
226         if (!$opt_NoTimes && (($twas||0)!=0))
227             {printf "%s", ((localtime $twas) =~ s/... //r =~ s/:.. / /r);}              # don't
include d-o-w, and drop seconds as that     implies precision
228     }

Not being a perl expert I'm not sure exactly what is wrong here. Can anyone please help determine
the issue?

Kind regards,
Tom

-- 

Tom Robinson
IT Manager/System Administrator

MoTeC Pty Ltd

121 Merrindale Drive
Croydon South
3136 Victoria
Australia

T: +61 3 9761 5050
F: +61 3 9761 5051   
E: tom.robinson@motec.com.au



Re: Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/... //r"

Posted by Daniel Staal <DS...@usa.net>.
--As of June 13, 2014 8:21:50 AM -0400, Joe Quinn is alleged to have said:

> On 6/12/2014 10:27 PM, Tom Robinson wrote:
>> Hi,
>>
>> Sorry to bother you with this. As referenced on the ApacheSpamAssassin
>> Wiki for AutoWhiteList
>> (https://wiki.apache.org/spamassassin/AutoWhitelist) I downloaded the
>> Truxoft version of the sa-heatu utility
>> (http://truxoft.com/resources/sa-heatu.v4.02.tar.gz ) but when I run it
>> I get these errors:
>>
>> Bareword found where operator expected at /usr/local/bin/sa-heatu line
>> 227, near "s/... //r" Bareword found where operator expected at
>> /usr/local/bin/sa-heatu line 227, near "s/:.. / /r" syntax error at
>> /usr/local/bin/sa-heatu line 227, near "s/... //r " Execution of
>> /usr/local/bin/sa-heatu aborted due to compilation errors.
>>
>> I'm running a CentOS 5.10, 32bit system.
>>
>> My version of perl is:
>> # perl -version
>> This is perl, v5.8.8 built for i386-linux-thread-multi
>> ---8<---snip*---
>>
>> I fetched a version of sa-heatu from git hub as well but it is the same
>> file (diff shows no differences and I get the same errors when running).
>>
>> Here is a snippet of the code in context:
>>
>> 224     if ($count && ($opt_verbose || ($opt_verboseHits &&
>> $count>$opt_verboseHits) || ($opt_showUpdates && $prtu))) {
>> 225         printf $fmt, $totscore/$count, $totscore,$count, $email,
>> $ip, $reason; 226         if (!$opt_NoTimes && (($twas||0)!=0))
>> 227             {printf "%s", ((localtime $twas) =~ s/... //r =~ s/:.. /
>> /r);}              # don't include d-o-w, and drop seconds as that
>> implies precision
>> 228     }
>>
>> Not being a perl expert I'm not sure exactly what is wrong here. Can
>> anyone please help determine the issue?
>>
>> Kind regards,
>> Tom
>>
> /r is not a valid regex modifier, and gets parsed as a bareword - see
> http://perldoc.perl.org/perlre.html#Modifiers

--As for the rest, it is mine.

That's not it: /r is a valid *substitution* modifier:

<http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators>

I'm not sure what the problem is though.  It *looks* ok to me.  It might be 
worth breaking line 227 into four lines just to see if that can show the 
problem better.

It should be equivalent to:

{
    my $temp = localtime $twas;
    $temp =~ s/:.. / /;
    $temp =~ s/... //;
    printf "%s", $temp;
}

(Note the /r is needed in the original because `localtime $twas` isn't 
something you can assign to.)

I'm not entirely certain on which order the strung-together substitutions 
are evaluated, or if it matters.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

Re: Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/... //r"

Posted by Joe Quinn <jq...@pccc.com>.
On 6/12/2014 10:27 PM, Tom Robinson wrote:
> Hi,
>
> Sorry to bother you with this. As referenced on the ApacheSpamAssassin Wiki for AutoWhiteList
> (https://wiki.apache.org/spamassassin/AutoWhitelist) I downloaded the Truxoft version of the
> sa-heatu utility (http://truxoft.com/resources/sa-heatu.v4.02.tar.gz ) but when I run it I get these
> errors:
>
> Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/... //r"
> Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/:.. / /r"
> syntax error at /usr/local/bin/sa-heatu line 227, near "s/... //r "
> Execution of /usr/local/bin/sa-heatu aborted due to compilation errors.
>
> I'm running a CentOS 5.10, 32bit system.
>
> My version of perl is:
> # perl -version
> This is perl, v5.8.8 built for i386-linux-thread-multi
> ---8<---snip*---
>
> I fetched a version of sa-heatu from git hub as well but it is the same file (diff shows no
> differences and I get the same errors when running).
>
> Here is a snippet of the code in context:
>
> 224     if ($count && ($opt_verbose || ($opt_verboseHits && $count>$opt_verboseHits) ||
> ($opt_showUpdates && $prtu))) {
> 225         printf $fmt, $totscore/$count, $totscore,$count, $email, $ip, $reason;
> 226         if (!$opt_NoTimes && (($twas||0)!=0))
> 227             {printf "%s", ((localtime $twas) =~ s/... //r =~ s/:.. / /r);}              # don't
> include d-o-w, and drop seconds as that     implies precision
> 228     }
>
> Not being a perl expert I'm not sure exactly what is wrong here. Can anyone please help determine
> the issue?
>
> Kind regards,
> Tom
>
/r is not a valid regex modifier, and gets parsed as a bareword - see 
http://perldoc.perl.org/perlre.html#Modifiers

Re: Bareword found where operator expected at /usr/local/bin/sa-heatu line 227, near "s/... //r"

Posted by Daniel Staal <DS...@usa.net>.
Please try to keep responses on-list; other people may have better answers 
than I do.  ;)

--As of June 16, 2014 10:58:29 AM +1000, Tom Robinson is alleged to have 
said:

> On 14/06/14 05:22, Christoph (Stucki) von Stuckrad wrote:
>> Hi! - and Sorry, all my tries to post did bounce.
>> Seemingly our updated mailsystem changed something.
>>
>> So directly to you and may be somebody can post it,
>> if it's useful.
>>
>> On Fri, 13 Jun 2014, Tom Robinson wrote:
>> ...[errormessage]...
>>
>> and Daniel Staal
>> ...[tied split into four lines, which will work]...
>>
>> Try changing
>>
>>> 227             {printf "%s", ((localtime $twas) =~ s/... //r =~ s/:..
>>> / /r);}
>>
>> to:               {printf("%s", ((localtime $twas) =~ s/... //r =~ s/:..
>> / /r));}
>>
>> There exist cases of ambiguity calling a function with a list of
>> parameters which themselves are lists and need (...).
>>
>> Then you fix the interpretation of the parameter list by the extra pair
>> of (...) around ALL the parameters of printf.
>>
>> Hope this helps, as I have not tested it, but experienced the
>> same problem many times in debug prints :-)
> Hi Christoph,
>
> Thanks for looking at this.
>
> I tried your suggestion but it didn't help. :-\
>
> I also tried Daniel's suggestion:
>
> {
>    my $temp = localtime $twas;
>    $temp =~ s/:.. / /;
>    $temp =~ s/... //;
>    printf "%s", $temp;
> }
>
> Which does allow the script to run.
>
> Daniel, you said that your fix *should* be equivalent. How will I know?
>
> Does any one else use this script? Where I can log a bug report?

Well, to be absolutely certain, you'd need to run it through B::Deparse 
read the output, but I don't think you'll need to go quite that far...

Mostly that was me saying 'I'm coding in the email client - no suitability 
for anything is guaranteed'.  I don't see any reason why it should be 
different in any cases - but I haven't researched all possible cases.  The 
only real difference is that I am using a temporary variable - and even 
there I suspect Deparse would show that Perl is using one anyway.

If you do file a bug report someplace, mention that they should take a look 
at the POSIX module and strftime - I have the *strong* suspicion that the 
whole convoluted mess could be replaced with one function call.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------