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 12:00:29 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



On 9/3/09 19:49, Rick Cooper wrote:
>
>
>   >  -----Original Message-----
>   >  From: mailscanner-bounces at lists.mailscanner.info
>   >  [mailto:mailscanner-bounces at lists.mailscanner.info] On
>   >  Behalf Of Julian Field
>   >  Sent: Monday, March 09, 2009 3:13 PM
>   >  To: MailScanner discussion
>   >  Subject: Re: Interesting Error - Can't use string ("1909")
>   >  as an ARRAY ref while "strict refs" in use
>   >
>   >  -----BEGIN PGP SIGNED MESSAGE-----
>   >  Hash: SHA1
>   >
>   >
>   >
>   >  On 9/3/09 13:52, Rick Cooper wrote:
>   >  >
>   >  >
>   >  >    >   -----Original Message-----
>   >  >    >   From: mailscanner-bounces at lists.mailscanner.info
>   >  >    >   [mailto:mailscanner-bounces at lists.mailscanner.info] On
>   >  >    >   Behalf Of Julian Field
>   >  >    >   Sent: Sunday, March 08, 2009 11:35 AM
>   >  >    >   To: MailScanner discussion
>   >  >    >   Subject: Re: Interesting Error - Can't use string ("1909")
>   >  >    >   as an ARRAY ref while "strict refs" in use
>   >  >    >
>   >  >    >
>   >  >    >
>   >  >    >   On 3/8/09 3:25 PM, Drew Marshall wrote:
>   >  >    >   >   ----- "Julian Field"<MailScanner at ecs.soton.ac.uk>    wrote:
>   >  >    >   >
>   >  >    >   >
>   >  >    >   >>   Okay, try changing your line 509 to say this instead:
>   >  >    >   >>   while(${@{$body}}[$#{@$body}] !~ /^\s*$/) {
>   >  >    >   >>   That does at least compile ( sorry about that :-(
>   >  >    >   >>
>   >  >    >   >   No worries. You are right it does compile but..
>   >  >    >   >
>   >  >    >   >   MailScanner --debug
>   >  >    >   >   In Debugging mode, not forking...
>   >  >    >   >   Trying to setlogsock(unix)
>   >  >    >   >   Building a message batch to scan...
>   >  >    >   >   Have a batch of 5 messages.
>   >  >    >   >   max message size is '250000 trackback'
>   >  >    >   >   Can't use string ("76") as an ARRAY ref while "strict
>   >  >    >   refs" in use at
>   >  >    >   /usr/share/MailScanner//MailScanner/PFDiskStore.pm line 509.
>   >  >    >   >
>   >  >    >   How about this then? (He says, desperately trying to work
>   >  >    >   around a nast
>   >  >    >   bug in Perl 5.10)
>   >  >    >
>   >  >    >   my $bodysize = $#{@$body}+0;
>   >  >    >   while (${@{$body}}[$bodysize+0] !~ /^\s*@/) {
>   >  >    >
>   >  >    >   If that doesn't work either, I give up.
>   >  >    >
>   >  >    >   Jules
>   >  >    >
>   >  >    And if that doesn't work wouldn't this do the same thing?
>   >  >
>   >  >  my @bodycheck = @{$body};
>   >  >
>   >  This will involve making a copy of the entire message in
>   >  memory. *Very*
>   >  expensive thing to do, need to avoid this at all costs.
>   >  >  for ($i=(@bodycheck-1);$i>= 0; $i--){
>   >  >  	last if @bodycheck[$i] =~ /^\s*$/;
>   >  >
>   >  you don't really mean @bodycheck[$i] do you? Surely you mean
>   >  $bodycheck[$i]?
>   >  >  	print "Line is ****". at bodycheck[$i]."****\n";
>   >  >  	pop @{$body};
>   >  >  }
>   >  >
>   >  So yes, it would do the same thing, but it will take a hell of a lot
>   >  longer to do, and will use a lot more memory too.
>   >  >  Rick
>   >  >
>   >  >
>
> Well really I doubt the need to make the copy, just seems somehow wrong to
> use a for loop on something that we are shortening with each iteration but
> since the loop is bottom up and the pop is from the bottom you could just
> use $body because you are effectively just operating on the last item at a
> given moment.
>
> And, pardon my lack of ability to wrap my head around perl's handling of
> arrays (yes I don't care what perl thinks, a hash is an associative array so
> it should be able to be addressed directly by index or by key without all
> the machinations) I think I would then mean
>
> for ($i=(@{$body}-1);$i>= 0; $i--){
> 	last if @{$body}[$i] =~ /^\s*$/;
>    
You can't do @array[$index] to access the index'th element of array.
You mean $body->[$i] I *think*. I must admit I get a bit lost in all the 
redirections at times myself :-)

for ($i=(@{$body}-1); $i>=0 $i--) {
   last if $body->[$i] =~ /^\s*$/;
   pop @{$body};
}

definitely looks possible.

> 	print "Line $i is ****".@{$body}[$i]."****\n";
> 	pop @{$body};
> }
>
> If we are trying to do this by index->value not key->value. Again I am
> assuming the point is to pop off the body info from the end forward until
> reaching either a blank line or a line of nothing but white space.
>
> ??
>
> Rick
>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
>    

Jules

- -- 
Julian Field MEng CITP CEng
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store

Need help customising MailScanner?
Contact me!
Need help fixing or optimising your systems?
Contact me!
Need help getting you started solving new requirements from your boss?
Contact me!

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654


-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.9.1 (Build 287)
Comment: Use Enigmail to decrypt or check this message is legitimate
Charset: ISO-8859-1

wj8DBQFJtlZeEfZZRxQVtlQRAic9AJ9JjKce9GGjQxAJSqT1n0EJo33j4QCgy/6V
PMe+TOKeuOCh1exGv4rHzdQ=
=U6re
-----END PGP SIGNATURE-----

-- 
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