in reply to help with REGEXP to remove carriage return and caret from end

In general, chomp() can be trusted to remove a trailing carriage return from your string. If chomp() doesn't work, then perhaps your string doesn't contain what you think it does.

A few obvious problems with your regular expression:

If I was looking for a series of word characters, I might prefer something like this, which looks for one or more characters in the word character class at the beginning of the string, and greedily captures them all into the $1 variable:

my $trimmed_user; if ($user =~ /^(\w+)/) { $trimmed_user = $1; }

Of course, this assumes that you won't have any characters in a user name that are not in the word character class (A-Za-z0-9_).


No good deed goes unpunished. -- (attributed to) Oscar Wilde

Replies are listed 'Best First'.
Re^2: help with REGEXP to remove carriage return and caret from end
by Bennco99 (Acolyte) on Jul 25, 2006 at 19:01 UTC
    Thank you ptum. Your recommendation did the trick. Thank you for your help.