in reply to What is missing from the beginning of this string?

I posted this in the wrong place first, so it may show twice

try something like this:

sub fix_URL { use URI; my $in = shift; my $url = URI->new($in); $url->scheme('http'); print "input is: $in\n"; print "fixed url is: $url\n"; }
perl> fix_URL 'tp://www.cnn.com' input is: tp://www.cnn.com fixed url is: http://www.cnn.com perl>

Replies are listed 'Best First'.
Re^2: What is missing from the beginning of this string?
by aquarium (Curate) on Oct 08, 2010 at 03:51 UTC
    excellent and elegant solution. the problem spec is still a bit hazy though. there's a whole host of urls that are not plain http://, do these also need pseudo-correction? e.g. https:, mailto:, javascript:, etc. even including browser specific ones such as those used in mozilla based browsers. if there's a need to fix all these other kinds of urls automatically, it would be pretty much impossible.
    the hardest line to type correctly is: stty erase ^H