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

#!/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;
Discipulus added correct ending code tag 28 Feb 2019 20:15 GMT+1

In reply to Word frequency from URL Doc by Boberts

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.