File: test06.p

package info (click to toggle)
libdevel-nytprof-perl 6.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,552 kB
  • sloc: perl: 5,616; javascript: 4,033; ansic: 107; makefile: 23
file content (44 lines) | stat: -rw-r--r-- 588 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# tests loops.  noop is a hack for perl>5.6 where
# the closing "}" of a loop counts as being executed if loop is empty.

my $_z;
sub noop { 
  $_z++;
}

sub foo {
  print "in sub foo\n";
  foreach (1 .. 10) {
    noop();
    foreach (1 .. 10) {
      noop();
    }
  }
}

sub bar {
  print "in sub bar\n";
  my ($x, $y);
  while (10 > $x++) {
    $y = 0;
    while (10 > $y++) {
      noop();
    }
  }
}

sub baz {
  print "in sub baz\n";
  my ($x, $y) = (1);
  do {
    $y = 1;
    do {
      noop();
      noop();
    } while(10 > $y++);
  } while(10 > $x++);
}

foo();
bar();
baz();