in reply to how to use chop / chomp effectively
Don't use chop/chomp, but rather the substitution operator:
In a regular expression, \s means "whitespace" which consists of spaces, tabs, carriage returns, line feeds, etc. The substitution says "substitute all whitespace at the end of the string with nothing", effectively removing it.my @lines = <$filehandle>; # read all lines s/\s+$// for @lines; # remove any whitespace at the end of eac +h line.
chop just removes the last character, whatever it happens to be and chomp just removes the trailing input record separator character sequence (typically just \n)
|
|---|