shell> perl -le '$_="foo,bar,baz"; print; s/,[^,]+$//; print' foo,bar,baz foo,bar