To get a word count, simply do this -use strict; use IO::File; die "usage: $0 [filename.txt]" if $#ARGV < 0; my $f = new IO::File $ARGV[0], "r" or die "File $ARGV[0] not found."; my $text = do {local $/; <$f>}; print <<HTML <html> <head><title>$ARGV[0]</title></head> <body> <pre> $text </pre> </body> </html> HTML ;
Update: Ops, someone reminded me that this is a homework question. I suddenly felt bad about giving out answers like that. But this solution isn't going to get 100% because it has hidden loop holes, so that's fair.my $wordcount = $text =~ /\w+/g;
In reply to Re: Need help with a Simple File, transferring a plain text document to a plain HTML document
by Roger
in thread Need help with a Simple File, transferring a plain text document to a plain HTML document
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |