Hi,

I use the following to read in lines from an uploaded file:

    my $fh = $q->upload('input_file');
    while (<$fh>) { push @urls, $_; }

It works fine when the file has UNIX or DOS linebreaks, but it fails with 
Macintosh linebreaks. What is the best method to read in a Macintosh file 
(other than splitting the file manually after reading it into one scalar)?

I obviously cannot send the input record separator to a pattern ("awk has to be 
better at something", The Camel).

Second question:

I am also a little confused about which line endings come with text uploaded 
via a textarea. I use:

    my $input = $q->param('input');
    $input =~ s/[\r\n]{2,}/\n/g;
    my @urls = split /\n/, $input;

to make sure I have not more than one linebreak. This works. But this also 
works:

    my $input = $q->param('input');
    $input =~ s/[\n]{2,}/\n/g;
    my @urls = split /[\r\n]+/, $input;

Note that I use a simple \n now in line 2 and the character class in line 3. 
But some mixtures of these two versions do not work.

Where can I read up on linebreaks as transferred by web browsers?

Thanks,

Jan
-- 
There's no place like ~/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to