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

Hello!! I'm newest of Perl. I have a log like this: 1. 14020493,user connected to system,11052010083612,192.168.7.8 2. admin,user connected,11052010091657,10.10.10.5 3. 16053070,data from server xyz apahce=9843685 sessione 4. abcir90458715,11052010091006,65.4.60.83 5 My problem is to parse line 3 and line 4, line 5 is ju a \n. How can I merge to line, like 3 and 4, in ones? Thanks in advance!

Replies are listed 'Best First'.
Re: Multiline Log to parse
by toolic (Bishop) on Jul 06, 2010 at 22:51 UTC
    Welcome to the Monastery.

    It would be better if you went back and updated your post to surround the lines of your file with code tags. Refer to Writeup Formatting Tips.

    The following merges lines 3 and 4:

    use warnings; use strict; while (<DATA>) { chomp if $. == 3; print; } __DATA__ 14020493,user connected to system,11052010083612,192.168.7.8 admin,user connected,11052010091657,10.10.10.5 16053070,data from server xyz apahce=9843685 sessione abcir90458715,11052010091006,65.4.60.83

    This is the output:

    14020493,user connected to system,11052010083612,192.168.7.8 admin,user connected,11052010091657,10.10.10.5 16053070,data from server xyz apahce=9843685 sessioneabcir90458715,110 +52010091006,65.4.60.83

    Since you are new to Perl, see also perlintro.