Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: URI plus File::Spec::Unix -- good idea or bad?

by mreece (Friar)
on Aug 24, 2006 at 21:43 UTC ( [id://569457]=note: print w/replies, xml ) Need Help??


in reply to Re: URI plus File::Spec::Unix -- good idea or bad?
in thread URI plus File::Spec::Unix -- good idea or bad?

of course, but my goal is to avoid the "if the $uri->path doesn't end in a slash do something different" part, if possible.
$uri->path( $uri->path =~ m{/$} ? $uri->path . 'index.html' : $uri->pa +th . '/index.html')
and similar seems more clumsy.

what i actually end up with is typically more like $base .= '/' unless $base =~ m{/$};, but i'm looking for something smarter, because i hate repeating these things and the problem is so easily solved (use File::Spec) with other file paths outside of URI context.

as for localization, that's why i used File::Spec::Unix explicitly, because you are correct, i don't need localization magic.

Replies are listed 'Best First'.
Re^3: URI plus File::Spec::Unix -- good idea or bad?
by duckyd (Hermit) on Aug 24, 2006 at 22:31 UTC
    Slightly less clumsy?
    $uri->path( $uri->path .( $uri->path =~ m{/$} ? '' : '/' ) .'index.html' );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://569457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found