[ale] Extraction of address and pages
Geoffrey
esoteric at 3times25.net
Thu Nov 4 15:31:13 EST 2004
Christopher Fowler wrote:
> I'm trying to get http://addr:port/page
>
> from:
>
> GET http://www.google.com/ HTTP/1.1
>
> this sucks as it is too greedy. Anyone have a suggestion.
> $m =~ m/http:\/\/(.+)\/\s+/;
>
> Thanks,
> Chris
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
A great tool no one uses much anymore:
echo http://addr:port/page|
awk -F'[:/]' '{for (i = 2; i<=NF; i++) printf "%s ", $i;}'
OR in perl:
#!/usr/bin/perl -w
use strict;
my $string = "http://addr:port/page";
my ($http, undef, undef, $addr, $port, $page, $rest) =
split(/[\/:]/, $string);
print "http is $http, addr is $addr, port is $port, page $page\n";
You'll have to deal with the possibility that there is not a port,
therefore shift stuff when there is no second ':' in the string.
--
Until later, Geoffrey
More information about the Ale
mailing list