arunmep has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys, I have a problem like Iam searching through a lot of files for a particular keywors and generating reports and a Html file with a link to the file by clicking the link the user can open the file directly. But the problem is when the file name contains a "space" the browser is replacing it with %20 by cliking those files names the browser does not recognize those files how can i solve this problem help me

Replies are listed 'Best First'.
Re: problem with file names
by grep (Monsignor) on Oct 01, 2006 at 06:41 UTC
    Use URI::Escape, the uri_unescape function will do what you want with spaces and any other URI escapes that work their way into the file name.

    Simple Example

    use URI::Escape; my $filename = uri_unescape('This%20is%20%an%20example.txt');


    grep
    Mynd you, mønk bites Kan be pretti nasti...
Re: problem with file names
by andyford (Curate) on Oct 01, 2006 at 06:08 UTC
    When you're generating the html, could you insert "%20" where you find spaces?
    Something like s/ /%20/g.
    Then your former, unclickable link like  <a href='file://space is the place'> would be transformed to  <a href='file://space%20is%20the%20place'>, thus rendering it clickable.

    Update: formatting.

    andyford
    or non-Perl: Andy Ford

Re: problem with file names
by sgifford (Prior) on Oct 01, 2006 at 17:12 UTC
    Just as your Web browser converts spaces to %20, your Web server should convert the %20 back to a space. Why don't you give us an example of exactly what the files are, what the HTML is, and what the browser does?