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

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



On Fri, Jan 22, 1999 at 06:33:57PM +0100, Lars G. Skjellerup wrote:
} Hi all
} 
} Before you all attack me for asking so stupid a question (:-) - I
} better say I am VERY new to Perl - actually this is my first
} week.
} 
} Ok here it comes - my problem:
} 
} 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.
} 
} 
} >From the FORM I could (It is user-input) get :
} 
} $File = "C:\Work\texts\document1.txt" (From PC)
} or
} $File = "Harddisk:Work:texts:document 1" (From Mac)
} 
} <SNIP>
} .
} .
} 	$Filename = $File;
} 
}         #Here I would like to get only the filename

use File::Basename;

$Fname = basename($Filename);

It's completely portable; it will work on Unix and MacOS, and should
work on Windblows.

} 	Fname = ???$Filename???
} 
} 	print("FILE = \"$Fname\"");
} .
} .
} <SNIP>
} 
} I am running the CGI as ACGI on a Web* server and pre made
} scripts run fine.
} 
} I know it must be simple, but as said I am very new, so any hints
} would be very appreciated.
} 
} Lot of thanks in advance.
} 
} Lars 'stenone' Skjellerup
} 
} -- 
} ************************************************************
} * Lars G. Skjellerup                                       *
} * Web designer/Programmer - Software Tester                * 
} *                                                          *
} * Silkeborg Bibliotek  Phone:  (+45) 86820233 ext. 380     *
} * Hostrupsgade 41 A    Fax:    (+45) 86802679              * 
} * DK 8600 Silkeborg    E-mail: stenone@silkeborg.bib.dk    *
} * Denmark                      stenone@netscape.net        *
} *                              stenone@hotmail.com         *
} *                              stenone@yahoo.com           *
} *                              stenone@forum.dk            *
} *                                                          *
} *                      URL:    http://www.silkeborg.bib.dk * 
} ************************************************************
} 

-- 
Paul Schinder
schinder@pobox.com

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