The following code gives the same double result
whereas omitting the .' ' as in the code below doesn't so its not part of the "" mechanism exactly.... my $o = ""; foreach ( @array ) { $o .= $_.' '; } print $o."\n";
If you modify your FETCH routine (more code below) to return an integer count for each time its called then you see that the calls used are the second ones. It is bizarre why Activestate should call the routine twice but it looks to me like a BUG as if you were using a more bizarre backend such as a network socket you'd be missing data.... my $o = ""; foreach ( @array ) { $o .= $_; } print $o."\n";
producesmy $c = 0; sub FETCH { my $self = shift; my $index = shift; $c++; print STDERR "Call ($c) fetching the element with index: $index\n" +; return $self->[ $index ].$c; }
Call (1) fetching the element with index: 0 Call (2) fetching the element with index: 0 Call (3) fetching the element with index: 1 Call (4) fetching the element with index: 1 Perl2 Monks4
Dingus
In reply to Re: Unexpected behaviour of a tied array (Bug in ActiveState Perl?)
by dingus
in thread Unexpected behaviour of a tied array (Bug in ActiveState Perl?)
by larsen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |