Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the fastest way to determine a full URL from a relative URL (given a base URL)

I'm currently using the module URI::URL to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster?

like image 837
lennysan Avatar asked Jan 24 '23 04:01

lennysan


2 Answers

Just happened across this article which point out shortcomings in Redhat/Centos/Fedora implementations of Perl which affect URI profoundly.

If you are running one of these Linux flavours, you might want to recompile Perl from original source (not RPM source).

I realized that anyone running perl code with the distribution perl interpretter on Redhat 5.2, Centos 5.2 or Fedora 9 is likely a victim. Yes, even if your code doesn’t use the fancy bless/overload idiom, many CPAN modules do! This google search shows 1500+ modules use the bless/overload idiom and they include some really popular ones like URI, JSON. ...

... At this point, I decided to recompile perl from source. The bug was gone. And the difference was appalling. Everything got seriously fast. CPUs were chilling at a loadavg below 0.10 and we were processing data 100x to 1000x faster!

like image 74
Brendan Avatar answered Jan 26 '23 16:01

Brendan


The following code should work.

$uri = URI->new_abs( $str, $base_uri )

You should also take a look at the URI page on search.cpan.org.

like image 25
Peter Stuifzand Avatar answered Jan 26 '23 17:01

Peter Stuifzand