http://qs321.pair.com?node_id=11130169


in reply to How to remove last character of a line

Given:

$line = '.abc(abc),';

You can remove the final character by simply saying:

chop $line;

This will remove ANY character, even a newline (\n). But to have a little more precision as to which character you might wish to remove, you could use a substitution:

$line =~ s/.$//; #remove the last character before the newline $line =~ s/[A-Za-z]$//; #remove an alphabetic character before the ne +wline $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 e +nd of the line

Blessings,

~Polyglot~