September 2002
Intermediate to advanced
496 pages
10h
English
Internally, PerlNET uses Perl interpreter. This allows us to incorporate all the standard Perl features and expressions in our PerlNET programs. This means that all samples that we introduced in Part 1 may be compiled and executed in the .NET environment without any changes. Let us demonstrate this by a simple Core Perl program, the standard Perl script freq.pl for counting word occurrences, which we presented in Chapter 4. Here is the code for the script.
#
# freq.pl
#
while(<STDIN>)
{
@words = split;
foreach $word (@words)
{
$words{$word}++;
}
}
foreach $word (sort(keys(%words)))
{
print "$word occurred $words{$word}\n";
}
Now, we may run the script either using Perl interpreter,
perl freq.pl
or by compiling into a .NET assembly ...