Interesting Error - Can't use string ("1909") as an ARRAY ref
while "strict refs" in use
Julian Field
MailScanner at ecs.soton.ac.uk
Sat Mar 7 20:49:10 GMT 2009
Okay, so the new chunk of code just there says this:
if ($configwords[1] =~ /tr[ua]/i) {
#print STDERR "Trackback:\n";
while(${@{$body}}[$#body] !~ /^\s*$/) {
#print "Line is ****" . ${@{$body}}[scalar(@{$body})-1] . "****\n";
pop @{$body};
#print STDERR ".";
}
#print STDERR "\n";
$b->Done();
return;
}
See if that helps your problem.
On 3/7/09 7:58 PM, 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: Saturday, March 07, 2009 1:08 PM
> > To: MailScanner discussion
> > Subject: Re: Interesting Error - Can't use string ("1909")
> > as an ARRAY ref while "strict refs" in use
> >
> >
> >
> > On 3/7/09 5:07 PM, Drew Marshall wrote:
> > > Rick
> > >
> > > On 7 Mar 2009, at 16:30, Rick Cooper wrote:
> > >
> > >> Been looking at this and really have no way to test
> > because I don't use
> > >> postfix but try changing
> > >>
> > >> while (${@{$body}}[scalar(@{$body})-1] !~ /^\s*$/) {
> > Doesn't scalar(@{$body})-1 need to be $#{@{$body}} or
> > something like that?
> > As it needs to de-reference $body into an array, and then
> > take $# of it?
> > $#body won't work as @body is not an array, @{$body} is the array.
> > >> print "Line is ****" .
> > ${@{$body}}[scalar(@{$body})-1] . "****\n";
> > >> pop @{$body};
> > >> #print STDERR ".";
> > >> }
> > >>
>
> This is what I get for not tracking everything from the beginning |-(
>
> If I am ready the calls through correctly (now) the ReadyBody function is
> call as
>
> ReadBody(\@original, MailScanner::Config::Value.....
>
> So my($body, $max) = @_;
>
> Is akin to my $body = \@orignal (I never looked at the top of the function
> to see it was $body, not @body)
>
> So
>
> while (${@{$body}}[$#body] !~ /^\s*$/) {
> print "Line is ****" . ${@{$body}}[$#body] . "****\n";
> pop @{$body};
> #print STDERR ".";
> }
>
>
> Now I am reading the code as cruise through the body from the last line up
> and pop the elements until we get to the first line that begins with white
> space. So I created this test (which works) :
>
> my @original = ('1', '2','3', '4', '5');
> my $body = \@original;
>
> while (${@{$body}}[$#body] !~ /^3$/) {
> print "Checking ****" . ${@{$body}}[$#body] . "****\n";
> pop @{$body};
> #print STDERR ".";
> }
>
> foreach $line(@{${body}}){
> print "Current Line : $line\n";
> }
>
> Running the program outputs
>
> Checking ****5****
> Checking ****4****
> Current Line : 1
> Current Line : 2
> Current Line : 3
>
> But now that I look at it, if the original code is just trying to read the
> last element anyway, why would you not just ${@{$body}}[-1] which is all
> $#body does anyway?
>
> I guess I must be confused, better have some beer.
>
> 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
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