diff options
author | dgp <dgp@users.sourceforge.net> | 2016-04-19 20:35:49 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-04-19 20:35:49 (GMT) |
commit | 66032e8a327e0498b0d8970307452f66c69be25c (patch) | |
tree | 345b92b9d0c1be0f8ff45032a38884929744545e /tests/langbench/wc.pl | |
parent | 0a228666ae8b3189ae92ff7624263de1455c24ff (diff) | |
download | tcl-66032e8a327e0498b0d8970307452f66c69be25c.zip tcl-66032e8a327e0498b0d8970307452f66c69be25c.tar.gz tcl-66032e8a327e0498b0d8970307452f66c69be25c.tar.bz2 |
Fork of Tcl used in the "Little" project.
http://www.mcvoy.com/lm/little/index.html
Diffstat (limited to 'tests/langbench/wc.pl')
-rw-r--r-- | tests/langbench/wc.pl | 23 |
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; |