in reply to Splitting an url in its components
If you are only interested in anything after the last slash, a regex should work fine:
if ($uri =~ m{([^/]+)\z}{ print $1, $/; }
Stripping the extension is a bit harder, because first you have to define what an extension is. If you just want to split off everything from the last period to the end, use a regex like this:
$filename =~ s/\.[^.]+\z//;
That will give you pkg-5.6.tar in the first example, which is technically correct, because you have a .tar file inside a .gz file. If you don't like that outcome, specify how the recognition of the extension should work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting an url in its components
by baurel (Sexton) on Jul 17, 2008 at 13:34 UTC | |
by moritz (Cardinal) on Jul 17, 2008 at 15:15 UTC | |
by baurel (Sexton) on Jul 17, 2008 at 15:42 UTC | |
by moritz (Cardinal) on Jul 17, 2008 at 15:48 UTC | |
by Anonymous Monk on Jul 18, 2008 at 04:44 UTC | |
by massa (Hermit) on Jul 17, 2008 at 22:08 UTC |