10 package Tie::BasicArray;
12 sub TIEARRAY { bless [], $_[0] }
13 sub STORE { $_[0]->[$_[1]] = $_[2] }
14 sub FETCH { $_[0]->[$_[1]] }
15 sub FETCHSIZE { scalar(@{$_[0]})}
16 sub STORESIZE { $#{$_[0]} = $_[1]+1 }
35 $a->{'a'} = 'A'; #should extend schema
40 if ($#keys == 3 && $#values == 3) {print "ok 1\n";} else {print "not ok 1\n";}
42 $i = 0; # stop -w complaints
44 while (($key,$value) = each %$a) {
45 if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
47 $i++ if $key eq $value;
51 if ($i == 4) {print "ok 2\n";} else {print "not ok 2\n";}
53 # quick check with tied array
54 tie @fake, 'Tie::StdArray';
59 if ($a->{'abc'} eq 'ABC') {print "ok 3\n";} else {print "not ok 3\n";}
61 # quick check with tied array
62 tie @fake, 'Tie::BasicArray';
67 if ($a->{'abc'} eq 'ABC') {print "ok 4\n";} else {print "not ok 4\n";}
69 # quick check with tied array & tied hash
71 tie %fake, Tie::StdHash;
76 if ($a->{'abc'} eq 'ABC') {print "ok 5\n";} else {print "not ok 5\n";}
79 my $slice = join('', 'x',@$a{'abc','def'},'x');
80 print "not " if $slice ne 'xABCx';