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;