in reply to reverse chop/string chop ?
Here's the problem: What if your database is screwed up and gives you back "http://www.mysite.com" as the result? Well, with the aforementioned solutions, your imagename will be "www.mysite.com", when it should be undef. Better is something along the lines of:
use URI::Split qw(uri_split); use File::Spec; my $url= get_url_from_database(); my ($scheme, $auth, $path, $query, $frag) = uri_split($url); die "No path in URI ($url) from database!" unless $path; my ($volume, $directory, $filename) = File::Spec->split_path($path); die "No filename in path ($path) from URI!" unless $filename;
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|