home *** CD-ROM | disk | FTP | other *** search
-
- print "1..3\n";
-
- #
- # routines to test the scalar and wantarray context built-ins
- #
-
- @foo = ('foo', 'bar', 'baz');
-
- $bar = "number of elements in foo is " . scalar(@foo);
-
- split (/ /, $bar);
-
- if ($_[6] eq "3") {print "ok 1\n";} else {print "not ok 1\n";}
-
- @foo = &test_wantarray(2, "array");
-
- $bar = &test_wantarray(3, "scalar");
-
- sub test_wantarray {
- local ($testnum, $type) = @_;
-
- if ($type eq "array") {
- if (wantarray) {
- print "ok $testnum\n";
- }
- else {
- print "not ok $testnum\n";
- }
- }
- else {
- if (!wantarray) {
- print "ok $testnum\n";
- }
- else {
- print "not ok $testnum\n";
- }
- }
- return wantarray ? () : "";
- }
-
-