Splitting URL into Patterns

--0016e6d27485497b4104a7f56b2e
Content-Type: text/plain; charset=ISO-8859-1

please I need to split a bunch of URL into their respective domain name
like abcd.com , it path direcory like /~bert/build/ , it's Argument
constitutent like uid =1

Take for example
msprogram.cn/update/ld.php?ld.php&id=1936&rs=1765405346&cc=0 &uid=1
I need the first match to be mspgroam.cn
The Directory to be /update/
The File should be ld.php

and argument should be a bunch of v=1 ,rs=1765405346 , cc=0 uid=1

I have tried replacing all the rules with a regular expression such as

$domain =~ s/[.]/<=>/g; # Substitute all values of . with <=
$domain =~ s/((?=(\w+|\d+))[?|&])/<=>/g ; # Substitute value with of word
starting with ? and ending with a & or space chomp has taken care of the
newlin
$domain =~ s/\//<=>/g;

running this 3 rule does not do the matching I am confused on how to go
about these .

Thanks for your wisdom

--
Akinleye Adedamola

--0016e6d27485497b4104a7f56b2e--
AKINLEYE [ Mi, 13 Juli 2011 17:53 ] [ ID #2062022 ]

Re: Splitting URL into Patterns

Hi Akinleye,

On Wed, 13 Jul 2011 16:53:35 +0100
AKINLEYE <damola.akinleye [at] gmail.com> wrote:

> please I need to split a bunch of URL into their respective domain name
> like abcd.com , it path direcory like /~bert/build/ , it's Argument
> constitutent like uid =3D1
>
> Take for example
> msprogram.cn/update/ld.php?ld.php&id=3D1936&rs=3D1765405346& cc=3D0&uid=3D1
> I need the first match to be mspgroam.cn
> The Directory to be /update/
> The File should be ld.php
>
> and argument should be a bunch of v=3D1 ,rs=3D1765405346 , cc=3D0 uid=3D1
>

For parsing URLs please see:

http://beta.metacpan.org/release/URI

Please do not do it using regular expressions.

Regards,

Shlomi Fish

--
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
"Humanity" - Parody of Modern Life - http://shlom.in/humanity

Real programmers don=E2=80=99t write workarounds. They tell their users to =
upgrade
their software.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Shlomi Fish [ Mi, 13 Juli 2011 18:08 ] [ ID #2062023 ]

Re: Splitting URL into Patterns

On 7/13/11 Wed Jul 13, 2011 8:53 AM, "AKINLEYE"
<damola.akinleye [at] gmail.com> scribbled:

> please I need to split a bunch of URL into their respective domain name
> like abcd.com , it path direcory like /~bert/build/ , it's Argument
> constitutent like uid =1
>
> Take for example
> msprogram.cn/update/ld.php?ld.php&id=1936&rs=1765405346&cc=0 &uid=1
> I need the first match to be mspgroam.cn
> The Directory to be /update/
> The File should be ld.php
>
> and argument should be a bunch of v=1 ,rs=1765405346 , cc=0 uid=1

Parsing URLs and URIs is a common problem. When encountering a problem like
this that other people may have encountered before, your first thought
should be to search the CPAN repository at <http://search.cpan.org> for an
appropriate module.

For example, a few minutes searching on the terms "URL" and "URI" revealed
the URI module, which may have exactly the functions you are looking for.

Example:

use URI;
my $uri = URI->new('http://msprogram.cn/update/ld.php?uid=1');
print $uri->host() . "\n";

Outputs:

msprogram.cn



--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Jim Gibson [ Mi, 13 Juli 2011 18:15 ] [ ID #2062024 ]
Perl » gmane.comp.lang.perl.beginners » Splitting URL into Patterns

Vorheriges Thema: Creating a detached process in perl cgi
Nächstes Thema: suggest me a perl script