Interesting Error - Can't use string ("1909") as an ARRAY ref
while "strict refs" in use
Julian Field
MailScanner at ecs.soton.ac.uk
Tue Mar 10 19:58:43 GMT 2009
On 10/3/09 18:58, Drew Marshall wrote:
>
> On 10 Mar 2009, at 17:55, Julian Field wrote:
>>>
>>> Julian, I believe you want for ($i=(@{$body}-1); $i>=0; $i--) {
>>> #decrement
>>> not increment
>>>
>> Of course I do, well done for spotting the intentional error, just
>> making sure you guys are kept on your toes ;-)
>
> Ok, so I now have (For the purposes of the record):
>
> if ($configwords[1] =~ /tr[ua]/i) {
> my $i;
> for ($i=(@{$body}-1); $i>=0; $i--) {
> last if $body->[$i] =~ /^\s*$/i;
> pop @{$body};
> }
> $b->Done();
> return;
> }
Correct.
>
> Which still works:
>
> MailScanner --debug
> In Debugging mode, not forking...
> Trying to setlogsock(unix)
> Building a message batch to scan...
> Have a batch of 1 message.
> max message size is '250000 trackback'
> commit ineffective with AutoCommit enabled at
> /etc/MailScanner/CustomFunctions/MailWatch.pm line 94, <CLIENT> line 61.
> Stopping now as you are debugging me.
>
> Still in production so tomorrow will give it a true test of a few '000
> messages but I'm more than sure it will be fine (But then I said that
> last time ;-) ).
Oh, how I love working round bugs in Perl :-)
Glad we got there in the end though, and the final code is a lot simpler
to read than my first version too. I didn't do it this way initially as
I don't like breaking out of "for" loops with "last", as that is what
the termination condition is for.
But it works, and that's the most important bit!
Jules
--
Julian Field MEng CITP CEng
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store
MailScanner customisation, or any advanced system administration help?
Contact me at Jules at Jules.FM
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
PGP public key: http://www.jules.fm/julesfm.asc
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the MailScanner
mailing list