in reply to Need help with a Simple File, transferring a plain text document to a plain HTML document

To generate the HTML -
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 ;
To get a word count, simply do this -
my $wordcount = $text =~ /\w+/g;
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.

  • Comment on Re: Need help with a Simple File, transferring a plain text document to a plain HTML document
  • Select or Download Code