in reply to Duplicate lines with spaces, tabs...

Your regex $_ =~ s/^\s+//; removes the leading spaces but not the trailing ones, so "5" is different from "5 " to your script.

Try adding $_ =~ s/\s+$//;

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."