Hi, I am new to Perl and I am trying to count the word frequency of a given txt document from a URL using the CGI stuff, I have this word frequency count which I took from the Learning Perl textbook but I don't know to get it to take it from a URL, any suggestions would be great
Discipulus added correct ending code tag 28 Feb 2019 20:15 GMT+1#!/usr/bin/perl use CGI qw(-utf-8 :all *table); use LWP::Simple qw(get); binmode(STDOUT, ":encoding(utf-8)"); print header(-charset=>'utf-8'), "\n", start_html({-title=>'URL retrieval', -author=>'Bob'}), "\n"; if (param('URL')) { my(@words, %count, $word); @words = get(param('URL')); foreach $word (@words) { $count {word} += 1; } foreach $word (keys %count) { print "$word was seen $count{word} times.\n"; } print start_table ({-border=>1}); print("Word Count Statistics for ".param('URL')), "\n"; print caption ("Frequency"); print end_table ; } print h1("URL retrieval"), "\n"; print start_form({-method=>"POST"}); print label("URL: "); print textfield({-name=>'URL', -size=>200}), "\n"; print br(), "\n"; print submit({-name=>'submit', -value=>'Process'}), "\n"; print end_form, end_html;
In reply to Word frequency from URL Doc by Boberts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |