The aforementioned example doesn't actually convert the forward slash. You could try URI escaping everything your file system disallows in a filename. On a Windows system, that would be \/:*?"<>|. The following shows how you can get valid, but funky looking filenames:
use strict; use URI::Escape; my @tests = ( "1/15/99-Bob.pdf", "test.txt", '\\/:*?"<>|' ); for ( @tests ) { print uri_escape( $_, ':\\\\\/*?"<>|' ), "\n"; }
That outputs the following:
1%2F15%2F99-Bob.pdf test.txt %5C%2F%3A%2A%3F%22%3C%3E%7C
This may not be your best options, but have you thought of creating directories like the following?
wwwroot -- documents --- 1 -- 25 -- 99 | -- 2 | -- 3
You actual pdf could then be named -Bruck.pdf and the path would work fine. Of course, I'd probably put the year first, but it does make for a handy organizational structure if you'll be working with many files.
One concern with your approach may be portability. Is that an issue? Do you want this to work with 8.3 filenames? Do all file systems allow for percent signs in filenames (though I don't know of any which don't).
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In reply to (Ovid) Re: Packing HTML Paths
by Ovid
in thread Packing HTML Paths
by skreuzer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |