CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Frequently Asked Questions:
How can I open a file with a leading "ż" or tr

 



Jasmine
Administrator

Jan 26, 2001, 10:21 AM

Post #1 of 1 (1696 views)
How can I open a file with a leading "ż" or tr Can't Post

(From the Perl FAQ)

How can I open a file with a leading "ż" or trailing blanks?

Normally perl ignores trailing blanks in filenames, and interprets certain leading characters (or a trailing ``|'') to mean something special. To avoid this, you might want to use a routine like this. It makes incomplete pathnames into explicit relative ones, and tacks a trailing null byte on the name to make perl leave it alone:

Code
    sub safe_filename { 
local $_ = shift;
return m#^/#
? "$_\0"
: "./$_\0";
}

$fn = safe_filename("<<<something really wicked ");
open(FH, "> $fn") or "couldn't open $fn: $!";

You could also use the sysopen() function (see sysopen).


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives