---- EwenMarshall <[EMAIL PROTECTED]> wrote: 
> Hi Guys,
> 
> How do I count matches in each line of a foreach loop...
> 
> Use strict;
> My ($line,@match_count);
> My @data = (";;;;ALM1;;\"Alarm 1\";;FINISH;", ";ALM2;;\"Alarm
> 2\";SCO;FINISH;");
> 
> Foreach $line (@data) {
> My $number=0;
> # Code to count ; in each line
> Push @match_count, "$number";
> }
> Print "Output: @match_count should eq 9 6";
> 
> Thanks in advance for any help.
> 
> Ewen
> 
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Hi Ewen,

How about using split function?  I mean something like:

my @myCounts = split @YourData, /;/
print $#myCounts;


--
Cheers,
WWang

+-Wenjie Wang aka William----------------------------------------+ 
| WANG Infonology Systems Pty Ltd - Your Partner for the Future  | 
| Phone : (02) 9871 2018  | [EMAIL PROTECTED]             | 
| Mobile: 0412 688 380    |http://www.wiseagent.com.au/          | 
+-------------------------+--------------------------------------+ 

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to