home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / perl / os2perl / for.t < prev    next >
Text File  |  1991-04-12  |  982b  |  50 lines

  1. #!./perl
  2.  
  3. # $Header: for.t,v 4.0 91/03/20 01:49:26 lwall Locked $
  4.  
  5. print "1..7\n";
  6.  
  7. for ($i = 0; $i <= 10; $i++) {
  8.     $x[$i] = $i;
  9. }
  10. $y = $x[10];
  11. print "#1    :$y: eq :10:\n";
  12. $y = join(' ', @x);
  13. print "#1    :$y: eq :0 1 2 3 4 5 6 7 8 9 10:\n";
  14. if (join(' ', @x) eq '0 1 2 3 4 5 6 7 8 9 10') {
  15.     print "ok 1\n";
  16. } else {
  17.     print "not ok 1\n";
  18. }
  19.  
  20. $i = $c = 0;
  21. for (;;) {
  22.     $c++;
  23.     last if $i++ > 10;
  24. }
  25. if ($c == 12) {print "ok 2\n";} else {print "not ok 2\n";}
  26.  
  27. $foo = 3210;
  28. @ary = (1,2,3,4,5);
  29. foreach $foo (@ary) {
  30.     $foo *= 2;
  31. }
  32. if (join('',@ary) eq '246810') {print "ok 3\n";} else {print "not ok 3\n";}
  33.  
  34. for (@ary) {
  35.     s/(.*)/ok $1\n/;
  36. }
  37.  
  38. print $ary[1];
  39.  
  40. # test for internal scratch array generation
  41. # this also tests that $foo was restored to 3210 after test 3
  42. for (split(' ','a b c d e')) {
  43.     $foo .= $_;
  44. }
  45. if ($foo eq '3210abcde') {print "ok 5\n";} else {print "not ok 5 $foo\n";}
  46.  
  47. foreach $foo (("ok 6\n","ok 7\n")) {
  48.     print $foo;
  49. }
  50.