On Tue, 15 Jan 2002, Joel Gwynn wrote:

> grrrrr.  I'm trying to parse an uploaded file that was created on a macintosh.  With 
>PC files, I use this snippet:
>
> my $rawfile = $cgi->param($p);
> my @data = <$rawfile>;
>
> which creates an array, each element of which is one line of text.  With files 
>created on a mac, the whole file gets put into $data[0], which is not what I want.  
>What's the best way to handle this, since I want to be able to handle files uploaded 
>by both mac and pc users?
>

Ack, wrong keys in the first attempt at this. What I have done in the
past, while perhaps not the most elegeant, is too see if @data only has
one element, if it does then just split that element on \r.

if(scalar(@data) == 1) {
        @data = split(/\r/, $data[0]);
}

and then process like you would normally.

Garth

Reply via email to