Help in unix script to join similar lines of input

Hi,
I have been thinking of how to script this but i have no clue at all..
Could someone please help me out or give me some idea on this?
I would like to group those lines with the same first variable in each line, joining the 2nd variables with commas.
Let's say i have the following input.

aa c1
aa c2
aa c3
cc d1
dd e1
dd e2
ee f1

I would like the output to be like this.

aa c1,c2,c3
cc d1
dd e1,e2
ee f1

Could this be easily done with bash script?
Or should i try perl script then?
I'm a beginner in bash script and perl.
Thank you.

Is file sorted on first column?

Try this ,

sort Filename| awk '{if(fld1==$1){printf ",%s",$2}else{printf "\n%s",$0}fld1=$1}'

GREAT !!!
I've found a solution to this by doing the following but i think your's is so smart. It just takes 1 line...:b:

for m in `cat ${input} | awk '{print $1}' | sort | uniq `
do
        var=`grep "^${m} " ${output} | awk '{print $2}' | tr '\n' ',' | sed '$s/,$//'`
        echo "${m} ${var}"
done