Front page | perl.libwww |
Postings from March 2003
From: Sean M. Burke
March 12, 2003 22:56
Message ID: email@example.com
One of the timid woodland creatures that read my /Perl and LWP/ book came
and asked me a question the other day. It's an interesting question with a
somewhat surprising answer, so I'll copy it here:
At 11:37 AM 2003-03-12 -0500, [some guy] wrote:
>Sorry to bug you, but I have a quick question I cant find the answer to.
>When using URI::URL (or normal URI) and breaking down a url to grab
>$url->path_segments(); is the first one that is returned always blank or
>is it just me? and if this is correct, why is it always blank? I find
>myself having to grab $blah to get the first actual segment.
I've been wondering about this for ages. But just now I thought of the
answer (or at least an answer): relative URL objects! They don't have to
start with a slash, so their $blah might have something in it.
% perl -d -e 1
Loading DB routines from perl5db.pl version 1.19
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
DB<1> use URI
DB<2> $x = URI->new('stuff/things')
DB<3> x $x->canonical->as_string
DB<4> x $x->path_segments
Sean M. Burke http://search.cpan.org/~sburke/
by Sean M. Burke