Let's suppose we have a text file named "file.csv" and want to count for each line the number of times a character is displayed, such as the character ",".
Suppose the result is the output of the same file "file.csv" preceded in each line by the count itself.
Just simply the following single line perl:
perl -ne '@c=$_=~/;/g; print scalar(@c)." ". $_;' file.csv