Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to match this URL but Its not working not matching at all ...

http://s48.turbobit.ru:9004/download.php?name=ATB+and+Armin+van+Buuren+-+Vice+Versa+%5Bworld-clubmusic.org%5D.mp3&md5=5aae327bd2fd7c176abf83474c5f8d69&fid=3spaskqfjxkm&uid=free&speed=55&till=1308055293&ip=84.22.91.71&trycount=1&sid=1a949a12128a9d1b9eb73ea2cba92f6a&browser=af8b7ed34111ff0bf53e39aff5bb1ad1&did=288302003&sign=f5f8344a2a456c4e53ab19616e123fb0

My Code is wrong but can somebody correct it for me ?

if (($u =~ /turbobit/) && (m/^http:\/\/(([A-Za-z]+[0-9-.]+)*?)([a-z]*\.[^\/]{3}\/[a-z]*\/[0-9]*)\/(.*?)\/([^\/\?\&]{4,})$/)) {
    print $x . "http://cdn." . $3 . "/SQUIDINTERNAL/" . $5 . "\n";
}

I want to store rewrite the uRL into :

http://cdn.turbobit.net/name=ATB+and+Armin+van+Buuren+-+Vice+Versa+%5Bworld-clubmusic.org%5D.mp3

I know It must work in other way like we can put (name=*?) into an element and then we can use it !

share|improve this question
add comment

1 Answer

It's not quite clear what you're trying to match here, as your regex implies you're trying to match more generally than your conditional and examples seem to indicate. I'm going to assume for the sake of my answer that you're looking for stuff coming from any subdomain of turbobit (under any TLD, any port) served by /download.php with a name parameter set.

# unless you really just want to match anything with turbobit in the url
# you should do this more explicitly
if ($u =~ m,http://(?:[^/]+\.)?turbobit\.[^/]+/,) {
    # this conditional will be clearer if you break it up

    # we're using the non-capture notation for most of these because it didn't
    # look like you were actually using this data.
    if ($u =~ m,^http://(?:[A-Za-z]+[0-9-]+\.)?turbobit\.[^/:]+(?::\d+)?/download\.php.*[?&]name=([^&]+),) {
        my $name = $1;

        # you can use the concatenate operator, but why not just interpolate?
        print "${x}http://cdn.turbobit.net/SQUIDINTERNAL/name=${name}\n";
    }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.