Count number of character occurence but not from quotation marks

I have the following string:

31-01-2012, 09:42:37;OK;94727132638;"Mozilla/5.0 (Linux; U; Android 2.2.1)";3G;WAP;

I need a script which is counting the occurrence of semicolons ( ; ) but exclude the ones from the quotation marks.
In the string given as example there are 8 semicolons but the script should return only 6, while 2 semicolons are in quotation marks (they are marked with red color).

Hi calinlicj,

One way. Remove all characters between double-quotes and then count semicolons:

$ perl -ne 's/"[^"]*"//g; printf qq[%d\n], tr/;/;/' <<<'31-01-2012, 09:42:37;OK;94727132638;"Mozilla/5.0 (Linux; U; Android 2.2.1)";3G;WAP;'
6

Regards,
Birei

perl -lne 's/\".*?\"//g;print s/;//g;' inputfile

Thank you both, Birei, balajesuri.