qadwjoh has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm trying to parse output from LWP::UserAgent. I'm sending a query to a CGI script and want to convert the ouput into an array using split:
@array = split /\n/, $ouput;
But this doesn't work as the resulting array only contains one line, which is the entire contents of $output (which when printed out is spread over several lines).

It seems the content of $output doesn't use \n as a new line character. I've tried using \r and \f, but to no avail

Any ideas?

Andrew

Replies are listed 'Best First'.
Re: Parsing output from LWP::UserAgent
by Happy-the-monk (Canon) on Mar 04, 2004 at 22:08 UTC
    the linebreak-sequence in webserver output is "\015\012" which only on some operating systems will be matched by "\n". You might want to try to split by /\015\012/ or /\015?\012/
Re: Parsing output from LWP::UserAgent
by Plankton (Vicar) on Mar 04, 2004 at 19:23 UTC
Re: Parsing output from LWP::UserAgent
by saintmike (Vicar) on Mar 04, 2004 at 19:34 UTC
    It would be interesting to see what kind of line separator is being used in the output. Try a hexdump to figure out the ascii code:

    use Data::Hexdumper; # from CPAN my $results = hexdump( data => $data, # what to dump ); print $results;

    -- saintmike