in reply to Removing multiple trailing comment lines from a string

$s =~ s/\n;.*\Z// for 1..3;

- tye