Reputation: 833
I have an old perl code which I need to improvise it by debugging it in apache server but it has some regular expressions in it which I am not able to figure out exactly as I am new to perl. Could some one please explain what does the following code do?
my $target = " ";
$target = $1 if( $url =~ m|^$shorturl(\/.*)$|);
Here, url is http://127.0.0.1/test.pl/content/dist/hale_bopp_2.mpg shorturl is http://127.0.0.1/test.pl
Upvotes: 0
Views: 344
Reputation: 386676
Is extracts the "path info" component of the URL, the extra segments of the path after the path to the script.
http://127.0.0.1/test.pl/content/dist/hale_bopp_2.mpg
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(It should really be $target = unescape_uri($1)
to handle escaped characters.)
Upvotes: 5
Reputation: 723
From the language perspective, it matches $url with regexp enclosed in m| | and if it matches, put first capture (part of regex in parens) into $target.
Upvotes: -1