First, please, instead of including your entire data set, whittle it down to an interesting subset.

Second, time for some Perl cleanup. Perhaps along the way we'll find your bug.

foreach(@search) { # We'll put the cleaned-up URL here temporarily. # We could do a push directly, but this will make # debugging easier. # my $ready; # You said you wanted to throw out mailtos # /^mailto:/ and next; # "if ($_ !~ /^http:\/\//gi)" # # /g is meaningless here; the caret can only match once. # "$_ !~ /.../" is a long way of saying "!/.../". # Pick your quotes to avoid Leaning Toothpick Syndrome. # And are you sure you want to start your if-else with # a negative test? # if (!m[^http://]i) { # "if ($_ !~ /^#/g)" # # Same as above # if (!/^#/) { $ready = "$base$_"; } } else # m[^http://] { # "if ($_ =~ /^\#/g)" # # But the first character can't be "#" because # at this point we know it's "h"! # Shorten; /g useless # if (/^#/) { $ready = "$url$_"; } else { $ready = $_; } } if (not defined $ready) { print "$_ was lost!<br>\n"; next; } print "$_ becomes $ready<br>\n"; # For debugging push @search_ready, $ready; }

Looks like we found the bug. I'm not quite sure what you're going for with the #'s, so I haven't tried to fix it. I highly suggest using positive tests in your if-elses. It tends to be less confusing.


In reply to Re: link parsing by TilRMan
in thread link parsing by coldfingertips

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.