On 4/3/02 4:02 PM, Pedro A Reche Gallardo <[EMAIL PROTECTED]>
wrote:

> Hi, I have a cgi script that uploads files but I have found that when
> those files are uploaded from a Mac or Windows the return character
> (maybe other characters too) are replaced by something else. Does any
> one know how to avoid this? or alternatively, how can I   translate
> those characters into the unix equivalents

Mac, Unix, and Windows all use different new-line characters. On a Mac, it's
\015, on Unix it's \012, and on Windows it's \015\012 (If you can't decide,
use both!). If you try to open a file from one system on another, you'll get
1 or 2 garbage characters each line.

You can quite easily convert files from one to the other like so:

$data =~ s/\015\012/\015/g;

Assuming $data is the slurped-up contents of a DOS file, that will convert
it to to Mac-style linebreaks.

<insert lecture about slurping up all the contents a file into one variable,
instead of looping through line by line>

hth,
-- 
Michael


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to