[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] How do I get filename from a URL ?



At 09:33 -0800 1/22/99, Lars G. Skjellerup wrote:
> I have a FORM (on a HTML-page on a server). I get all the right
> info to my CGI (if I output it on a page I can read all that is
> expected) - but now I would very much like to extract a filename
> from a path.


At 09:48 -0800 1/22/99, Paul J. Schinder wrote:
> use File::Basename;
>
> $Fname = basename($Filename);


At 11:17 -0800 1/22/99, Christopher F. Blanford wrote:
> $file =~ m!(:|/)(.*)$!;
> $Fname = $2;

I would second Paul. File::Basename is more portable as well as tested/
standard/ etc... It even handles, can you believe it, VMS filenames ;-)
Get to know the File:: modules; they are your friends.

You might also, depending upon what you are ultimately trying to
accomplish, check into using cgi.pm to create and run your form.

Netscape and (I think) IE both allow file uploads in recent versions.  If
you're trying, ultimately, to access the _file_, cgi.pm and file uploads
make this very simple. CGI.pm handles accepting the file, opening it, and
handing back a filehandle, all "magically".

Now in book form... CGI.pm makes forms based cgi-stuff easier.

- Vicki
---
      |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
     |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
    '---''(_/--'  `-'\_)       http://www.cfcl.com/~vlb  www.ptf.com/macperl

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch