Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: File::Basename and File::MMagic for File Downloads from Website

by fmerges (Chaplain)
on Nov 21, 2008 at 04:16 UTC ( #725053=note: print w/ replies, xml ) Need Help??


in reply to File::Basename and File::MMagic for File Downloads from Website

Hi,

You can try like this:

use strict; use FileUpload::Filename; # Usually used in combination with the upload handler, so it will be # implicitely set. $ENV{HTTP_USER_AGENT} = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT + 5.1; .NET CLR 2.0.50727; Zune 2.0)'; my $name = FileUpload::Filename->name({ filename => 'Z:\my_files\docs\some_kind_of_manual.pdf', }); print "[$name]\n"; $name = FileUpload::Filename->name({ filename => '/home/someguy/file.txt', }); print "[$name]\n"; $name = FileUpload::Filename->name({ filename => 'home:anotherguy:A Music Song.mp3', }); print "[$name]\n";

Output:

[some_kind_of_manual.pdf] [file.txt] [A_Music_Song.mp3]

Curiously with the agent set as IE, it works for the three inputs :-)

Regards,

fmerges at irc.freenode.net


Comment on Re: File::Basename and File::MMagic for File Downloads from Website
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-29 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls