Well, being way down on the perl food chain, i interpreted (mis-interpreted?) this 
request a little 
different and offer a simplistic and not entirely correct approach but still i would 
like to offer it.

It seemed to me that he was looking to split() the line into month | date | time | 
byte size
and sort() the line by month | date, and i kind of stopped there. I though by implying 
that he was
'learning perl' he was using a log file for 'parsing' practice.  And rather than a RE 
was looking for 
a built in function of some sort. I have no idea about sorting through a 1GB file, 
(which is much larger 
then my whole /var partition) i have no desire to try it on my machine at the moment.

This sorts numerically by month and date, (i.e Aug=A is first Dec=D is second, Feb=F 
is 3rd, etc,etc, 
but they are grouped together) if you wanted to put the months in the correct order it 
would be 
easy enough to load them into a hash as RN suggested,... i've still got the secret 
decoder ring out
for the other hieroglyphics contained in his code, cool,... 


#!/usr/bin/perl -w

#*******************************************************************************
#I'm teaching myself Perl and I have a log file around 1GB that I need to sort
#by month | date | time | byte size. So far I have parse the log for "bytes"
#since this is all that I need but I can't get it to sort like I want.
#
#Here is the Data I parsed for bytes but now I need to sort by month | date |
#time | byte size.
#*******************************************************************************

use strict;
my($month, $date, $time, $byte_size, @all_data, %paired_data, $m_date, $t_byte);
my(@m_date, @t_byte, @f_date);
my($four, $five, $six, $seven, $eight, $nine, $ten);
my $num = 0;

while(<DATA>) {
    if(/^[A-Z]/) { # If line start with a Caps (month) as below,
       ($month, $date, $time, $four, $five, $six, $seven, $eight, $nine, $ten, 
$byte_size) = split;
         $m_date[$num] = $month ." ". $date . " " . $time . " " . $byte_size . "\n";
         @f_date = sort @m_date;
         $num++;
    }
}
         print @f_date;




__DATA__
Aug  3 04:02:02 node qmail: 1028545322.562816 info msg 401391: bytes 4138
from <#@[]> qp 1367 uid 507
Aug  2 04:02:57 node qmail: 1028545377.266421 info msg 401390: bytes 614
from <[EMAIL PROTECTED]> qp 1558 uid 0
Aug  1 04:02:57 node qmail: 1028545377.340607 info msg 401393: bytes 1206
from <> qp 1561 uid 507
Aug  4 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 1701
from <#@[]> qp 1564 uid 507
Aug  5 04:02:02 node qmail: 1028545322.562816 info msg 401391: bytes 4138
from <#@[]> qp 1367 uid 507
Aug  9 04:02:57 node qmail: 1028545377.266421 info msg 401390: bytes 614
from <[EMAIL PROTECTED]> qp 1558 uid 0
Aug  7 04:02:57 node qmail: 1028545377.340607 info msg 401393: bytes 1206
from <> qp 1561 uid 507
Aug  8 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 1701
from <#@[]> qp 1564 uid 507
Jan  2 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 1101
from <#@[]> qp 1564 uid 507
Jul  5 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 5701
from <#@[]> qp 1564 uid 507
Jul  3 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 101
from <#@[]> qp 1564 uid 507
Jan  21 04:02:57 node qmail: 1028545377.423885 info msg 401391: bytes 701
from <#@[]> qp 1564 uid 507

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

Reply via email to