All I want to do is count the number of ;'s on each line of 15,000'ish lined text file. The first 3 lines look like (FINISH; is the end of 1 line):
NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.00000; 0.00000;"ANALOGUE CARD #100 INPUT NO 01";FLOAT;FINISH; NEW ANALOGUE; A.PS.19.602; 1; 4;NA; 0;OFF;%;NO; 100.00000; 0.00000;"ANALOGUE CARD #100 INPUT NO 02";FLOAT;FINISH; NEW ANALOGUE; A.PS.19.603; 2; 4;NA; 0;OFF;%;NO; 100.00000; 0.00000;"ANALOGUE CARD #100 INPUT NO 03";FLOAT;FINISH; Basically the file is an export from a very old database and there is not always the same amount of ;'s in each line. I've been given the lovely task of changing the format so that each line in the file can be imported into an access database from a ; delimited file in the correct order. The match condition is number of ; in 1 line Output: found 14 ; in 1,232 lines found 13 ; in 7,456 lines found 12 ; in 2,321 lines I only need total number of lines found. I do not know what the max or min amount of ;'s there can be in one line. Ewen -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Wagner Sent: 05 December 2006 18:50 To: Perl-Win32-Users@listserv.ActiveState.com Subject: Re: Counting Matches In A Line We need some more information. What is the match condition and how do u find the number of matches? If ur just trying to record the number of "something" per line so that u can go back and correlate the number to the line, then u can't use foreach. U have to iterate over the array so u can get the offset. for $i (0 .. $#data) { $number = 0 + do_something; $matchcount[$i] = $number; } Now $matchcount[$i] corresponds to the number of matches in $data[$i]. -- REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=-- "...ne cede malis" 00000100 _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs