Simple example to extract, protocol, server and domain from a given URL:
1 2 3 4 5 6 7 |
my $test = "http:www.test.com"; $test =~ /^(?<protocol>.+)\:(?<server>.+)\.(?<domain>.+)$/; print "protocol : ".$+{protocol}."\n"; print "Server : ".$+{server}."\n"; print "Domain : ".$+{domain}."\n"; |
Our Result:
1 2 3 4 |
sh-4.3$ perl main.pl protocol : http Server : www.test Domain : com |