summaryrefslogtreecommitdiffstats
path: root/tests/langbench/wc.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/langbench/wc.pl')
-rw-r--r--tests/langbench/wc.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/langbench/wc.pl b/tests/langbench/wc.pl
new file mode 100644
index 0000000..0853908
--- /dev/null
+++ b/tests/langbench/wc.pl
@@ -0,0 +1,23 @@
+sub wordsplit
+{
+ chomp($_[0]);
+ @list = ();
+ $word = "";
+ foreach $c (split(//, $_[0])) {
+ if ($c =~ /\s/o) {
+ push(@list, $word) if $word ne "";
+ $word = "";
+ } else {
+ $word .= $c;
+ }
+ }
+ push(@list, $word) if $word ne "";
+ return @list;
+}
+
+$n = 0;
+while (<>) {
+ @words = &wordsplit($_);
+ $n += $#words + 1;
+}
+printf "%d\n", $n;