How can I remove trailing commas?



How can I remove any trailing commas from the end of $var?

I tried using

$var =~ s/,+$//

but it didn't work.

.