in reply to Help with Toke Parser

I haven't ever used HTML::TokeParser so I'm unaware on how to get the file's size, but your array issue looks like it stems from the fact you're overwriting it in each loop, which explains why you are only getting the last element (actually, there would only be a single element, the one produced in the last loop of while()):

@array = $token->[1]{href} || "-";

I think what you want is this instead (see push):

push @array, $token->[1]{href} || "-";

Then it may be best to do the cleanup after while() loop:

my $p= HTML::TokeParser->new(\$page); while (my $token = $p->get_tag("a")) { push @array, $token->[1]{href} || "-"; my $text = $p->get_trimmed_text("/a"); } for (@array){ next if /^-$/; # skip if line eq '-' s/ test.txt | \/ | \?C\=N;O\=D | \?C\=M;O\=A | \?C\=S;O\=A | \?C\=D;O\=A //xg; }

To understand how I've turned your multiple regexes into a single one with embedded whitespace for clarity, see x modifier in perlre.