$line =~ s/.$//; #remove the last character before the newline $line =~ s/[A-Za-z]$//; #remove an alphabetic character before the newline $line =~ s/;$//; #remove a semicolon at the end of the line $line =~ s/[ ]$//; #remove a single space at the end of the line $line =~ s/\s+$//; #remove one or more whitespace characters at the end of the line