in reply to How to remove last character of a line

Note that both chomp() and chop() modify their argument in-place and return the removed character. So if $line contains '.abc(abc),, your example code will print either '' (i.e. the empty string) as written, or ',' if you use chop(). If you want your output to be '.abc(abc)', you will need to print $temp_out $line;.

Replies are listed 'Best First'.
Re^2: How to remove last character of a line
by haukex (Archbishop) on Mar 23, 2021 at 15:53 UTC
    Note that both chomp() and chop() modify their argument in-place and return the removed character.

    No, only chop returns the removed character. chomp returns the total number of characters removed.

    Edit: Made first sentence more specific.