Learning perl
public text v1 · immutable#!/usr/bin/perl
use strict;
@lines=(<>); # Read from stdin or a file
for $i (@lines) { # Parse each line into words?
@line = split(' ',$i);
for $w (@line) {
$wordcount{$w}++;
print "$w\n";
}
}
for $w (keys %wordcount) { # Read out the hash table nicely.
print "$wordcount{$w}\t$w\n";
}
print "There are $#lines lines\n";