Here is the output I got: "2002-08-28","Tape 1", "staff", "315825" "2002-08-28","Tape 2", "www.cs", "102860" "2002-08-28","Tape 2", "staff_homepages", "103142" "2002-08-28","Tape 2", "ftp.cs", "103204" "2002-08-28","Tape 2", "local", "103216" "2002-08-28","Tape 2", "Hyper-G", "103236" "2002-08-28","Tape 2", "submissions", "104278" "2002-08-28","Tape 2", "src", "110373" "2002-08-28","Tape 2", "IMAP", "110455"
from the snippet: #!perl -w my $MyTape = 1; my ($MyCurrDate, $MyCurrTape, $MyCurrDesc, $MyCurrBlock) = ('','','',''); my ($MyPrevBlock) = (0); while (<DATA>) { chomp; if ( /\sof\s+([^\s]+).+(\d{4}-\d{2}-\d{2}).+block\s+(\d+)/i ) { $MyCurrDesc = $1; $MyCurrDate = $2; $MyCurrBlock = $3; $MyTape++ if ( $MyCurrBlock < $MyPrevBlock); $MyCurrTape = $MyTape; printf "\"%-s\",\"Tape %d\", \"%-s\", \"%d\"\n", $MyCurrDate, $MyCurrTape, $MyCurrDesc, $MyCurrBlock; $MyPrevBlock = $MyCurrBlock; } } __DATA__ INCREMENTAL OF staff ON 2002-08-28 FROM 08/27/02 STARTS AT At block 315825. INCREMENTAL OF www.cs <http://www.cs> ON 2002-08-28 FROM 08/27/02 STARTS AT At block 102860. INCREMENTAL OF staff_homepages ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103142. INCREMENTAL OF ftp.cs <ftp://ftp.cs> ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103204 INCREMENTAL OF local ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103216. INCREMENTAL OF Hyper-G ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103236. INCREMENTAL OF submissions ON 2002-08-28 FROM 08/27/02 STARTS AT At block 104278. INCREMENTAL OF src ON 2002-08-28 FROM 08/27/02 STARTS AT At block 110373. INCREMENTAL OF IMAP ON 2002-08-28 FROM 08/27/02 STARTS AT At block 110455. Wags ;) -----Original Message----- From: LADDO [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 27, 2002 15:59 To: [EMAIL PROTECTED] Subject: sorting logs Hi all I have a log file which is generated by backup script and i am writing a perl script to sort the log so as to prepare it to put into mysql database and iam having a problem in doing that. my log file is like this (I have written line numbers for clarity only ) 1 INCREMENTAL OF staff ON 2002-08-28 FROM 08/27/02 STARTS AT At block 315825. 2 INCREMENTAL OF www.cs <http://www.cs> ON 2002-08-28 FROM 08/27/02 STARTS AT At block 102860. 3 INCREMENTAL OF staff_homepages ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103142. 4 INCREMENTAL OF ftp.cs <ftp://ftp.cs> ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103204 5 INCREMENTAL OF local ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103216. 6 INCREMENTAL OF Hyper-G ON 2002-08-28 FROM 08/27/02 STARTS AT At block 103236. 7 INCREMENTAL OF submissions ON 2002-08-28 FROM 08/27/02 STARTS AT At block 104278. 8 INCREMENTAL OF src ON 2002-08-28 FROM 08/27/02 STARTS AT At block 110373. 9 INCREMENTAL OF IMAP ON 2002-08-28 FROM 08/27/02 STARTS AT At block 110455. i want a script that can give me output like this "2002-08-28","$PROBLEM","staff", "315825" $PROBLEM is actually tape number which should be derived from blocknumbers in the logfile e.g say the initial TAPE No =1 and the script should check if the block number is greater than the block number in the next line it should replace $PROBLEM with TAPE 1 Other wise should do something like $PROBLEM=$TAPE +1 Like in my example line 1 should give the output as "2002-08-28","TAPE 1","staff", "315825" # because 315825 > 102860 line 2 should be "2002-08-28", "TAPE 2","www.cs", "102860" # tape=$tape +1 is required because 102860 ! > 103142 and the same with other lines .... i can do it with awk and bash but as iam learning perl iam trying to write everything in perl. For all the guru's out there i know its very simple please help Hmmm i hope i have explained the concept correctly Cheers Bobby -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]