good day monks

I have a script that will be used in a larger script but this part is giving me some trouble.

My goal for this part of the script is to perform a file listing on a webpage and into a hash with filename as key and file size as value.

But I have been unable to find a way to get filesize so I have tried to do it with just an array of filenames.

Here is the code as it currently stands, the issue is that it only prints the last element outside the loop, inside the loop it prints all of them. If anyone has a way to get it work with a hash as mentioned above, I'd rather that than messing with the array problem.
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use HTML::TokeParser; use LWP::Simple; use File::Basename; use List::Compare; ## POC URL: my $page=get('http://localhost/images'); my %urlhash; my @urlfiles; my @array; my @newarray; my $p= HTML::TokeParser->new(\$page); while (my $token = $p->get_tag("a")) { @array = $token->[1]{href} || "-"; my $text = $p->get_trimmed_text("/a"); ## Just a few lines of crap cleaner... for (@array) {s/test.txt//g}; for (@array) {s/\///g}; for (@array) {s/\?C\=N;O\=D//g}; for (@array) {s/\?C\=M;O\=A//g}; for (@array) {s/\?C\=S;O\=A//g}; for (@array) {s/\?C\=D;O\=A//g}; #print "@array\n"; } print "@array\n";

The crap cleaner section is to remove that from the webpage. I have removed it on my POC Apache server, but it exists on the server I will run it against, which I have no control over.

Thanks in advance!


In reply to Help with Toke Parser by StarkRavingCalm

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.