in reply to url and arrays

URL's can be tricky. Maybe your case is fairly trivial, but why not use a tool known to work? URI::Split

use Modern::Perl; use URI::Split qw/uri_split/; my %parts; @parts{ my @keys = qw/ scheme auth path query frag / } = uri_split( 'http://www.bing.com/default.aspx' ); say "$_ => $parts{$_}" for grep { defined $parts{$_} } @keys;

The output is

scheme => http auth => www.bing.com path => /default.aspx

Dave

Replies are listed 'Best First'.
Re^2: url and arrays
by armstd (Friar) on Jul 02, 2011 at 19:25 UTC
    URL's can be tricky. Maybe your case is fairly trivial, but why not use a tool known to work? URI::Split

    Not only is it known to work, but it is intended to continue working, for the OP's specific intended purpose. When found not to work, it shall be fixed. It's the right solution today and tomorrow. That's the textbook reason for reusing code like this.

    --Dave