Lightning flashed, thunder crashed and "Collin Rogowski" <[EMAIL PROTECTED]> w
hispered:
| They exist both.
| chop removes the last character.
| chomp removes the last character if it's newline.

Let's get this straight and correct.  chomp removes the input record
separator ($/).  This may or may not be a newline.

| Maybe your file has DOS-Newlines which are to characters (\r\n).
| If you chop, you keep \r at the end which could mess around with
| printing it. Perhaps you should try a double chop or something
| more sophisticated like:

chomp should handle this case correctly.

| $string =~ s/[^\da-ZA-Z-_]*$//;

That's ugly.  Especially as it could be much more cleanly written as
s/(\D\W)+$//.  \D is a non-digit, \W is a non-word character.  Also, use +
instead of *.  It's a little performance enhancer.  * can match nothing, so
you could end up replacing nothing with nothing.  + must match at least a
single character, so if there's nothing to replace, nothing happens.

-spp

Reply via email to