if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
-while (($key,$value) = each(h)) {
+while (($key,$value) = each(%h)) {
if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
$key =~ y/a-z/A-Z/;
$i++ if $key eq $value;
if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
-@keys = ('blurfl', keys(h), 'dyick');
+@keys = ('blurfl', keys(%h), 'dyick');
if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
$h{'foo'} = '';
if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
-while (($key,$value) = each(h)) {
+while (($key,$value) = each(%h)) {
if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
$key =~ y/a-z/A-Z/;
$i++ if $key eq $value;
if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
-@keys = ('blurfl', keys(h), 'dyick');
+@keys = ('blurfl', keys(%h), 'dyick');
if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
$h{'foo'} = '';
if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
-while (($key,$value) = each(h)) {
+while (($key,$value) = each(%h)) {
if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
$key =~ y/a-z/A-Z/;
$i++ if $key eq $value;
if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
-@keys = ('blurfl', keys(h), 'dyick');
+@keys = ('blurfl', keys(%h), 'dyick');
if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
$h{'foo'} = '';
if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
-while (($key,$value) = each(h)) {
+while (($key,$value) = each(%h)) {
if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
$key =~ y/a-z/A-Z/;
$i++ if $key eq $value;
if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
-@keys = ('blurfl', keys(h), 'dyick');
+@keys = ('blurfl', keys(%h), 'dyick');
if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
$h{'foo'} = '';
if ($#keys == 29 && $#values == 29) {print "ok 5\n";} else {print "not ok 5\n";}
-while (($key,$value) = each(h)) {
+while (($key,$value) = each(%h)) {
if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
$key =~ y/a-z/A-Z/;
$i++ if $key eq $value;
if ($i == 30) {print "ok 6\n";} else {print "not ok 6\n";}
-@keys = ('blurfl', keys(h), 'dyick');
+@keys = ('blurfl', keys(%h), 'dyick');
if ($#keys == 31) {print "ok 7\n";} else {print "not ok 7\n";}
$h{'foo'} = '';
# $RCSfile: array.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:37 $
-print "1..39\n";
+print "1..40\n";
@ary = (1,2,3,4,5);
if (join('',@ary) eq '12345') {print "ok 1\n";} else {print "not ok 1\n";}
};
print "not " unless $@ =~ /Can't multiply inherit %FIELDS/;
print "ok 39\n";
+
+@foo = ( 'foo', 'bar', 'burbl');
+push(foo, 'blah');
+print $#foo == 3 ? "ok 40\n" : "not ok 40\n";
if ($foo{1} eq 'a') {print "ok 12\n";} else {print "not ok 12\n";}
if ($foo{3} eq 'c') {print "ok 13\n";} else {print "not ok 13\n";}
-$foo = join('',values(foo));
+$foo = join('',values(%foo));
if ($foo eq 'ac' || $foo eq 'ca') {print "ok 14\n";} else {print "not ok 14\n";}
-foreach $key (keys foo) {
+foreach $key (keys %foo) {
delete $foo{$key};
}
$foo{'foo'} = 'x';
$foo{'bar'} = 'y';
-$foo = join('',values(foo));
+$foo = join('',values(%foo));
print +($foo eq 'xy' || $foo eq 'yx') ? "ok 15\n" : "not ok 15\n";
$refhash{"top"}->{"foo"} = "FOO";
# $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
-print "1..14\n";
+print "1..16\n";
$h{'abc'} = 'ABC';
$h{'def'} = 'DEF';
print "not " if keys(%hash) != 10;
print "ok 14\n";
+print keys(hash) != 10 ? "not ok 15\n" : "ok 15\n";
+
+$i = 0;
+%h = (a => A, b => B, c=> C, d => D, abc => ABC);
+@keys = keys(h);
+@values = values(h);
+while (($key, $value) = each(h)) {
+ if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
+ $i++;
+ }
+}
+if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }
@a = (1,2,3,4,5,6,7,8,9,10,11,12);
-while ($_ = shift(a)) {
+while ($_ = shift(@a)) {
if ($x = /4/../8/) { $z = $x; print "ok ", $x + 0, "\n"; }
$y .= /1/../2/;
}
$XXX{345} = 345;
@XXX = ('ok 25','not ok 25', 'ok 26','not ok 26','not ok 27');
-while ($_ = shift(XXX)) {
+while ($_ = shift(@XXX)) {
?(.*)? && (print $1,"\n");
/not/ && reset;
/not ok 26/ && reset 'X';
-4, 4 5 6 7, 0 1 2 3
EOF
-print "1..", 2 + @tests, "\n";
+print "1..", 4 + @tests, "\n";
die "blech" unless @tests;
@x = (1,2,3);
push(@x,4);
if (join(':',@x) eq '1:2:3:1:2:3:4') {print "ok 2\n";} else {print "not ok 2\n";}
-$test = 3;
+# test for push/pop intuiting @ on array
+push(x,3);
+if (join(':',@x) eq '1:2:3:1:2:3:4:3') {print "ok 3\n";} else {print "not ok 3\n";}
+pop(x);
+if (join(':',@x) eq '1:2:3:1:2:3:4') {print "ok 4\n";} else {print "not ok 4\n";}
+
+$test = 5;
foreach $line (@tests) {
($list,$get,$leave) = split(/,\t*/,$line);
($pos, $len, @list) = split(' ',$list);