while (<>) { # $ denotes end of string s/AAAAA$//; s/>CC\@B$//; print; }