Jamie Risk wrote:
> Okay, I do know that binary transfer of a text file between DOS and
> Unix systems is a non-non, but my Samba setup isn't that
> discriminating. 
> 
> Perl is running on a Unix platform, and 'chomp' isn't quite up to the
> task of removing CR (ASCII '\r' or 0x0D).

It is if you set $/="\r\n"

> So I tried:
>   s/(.+)[ \t\n\r]*/$1/
> but those tricky little CR are still there. Even
>   s/(.+)[ \t\n\r\015]*/$1/
> still eludes me.
> 
> Someone please explain the source of my confusion.

Because a dot (.) matches \r, the (.+) gobbles up your \r so that the
character class that follows can't match it. No backtracking is required,
since you use '*' (match zero or more) on your character class. Changing the
* to a + should make it work. But there are simpler ways:

To strip a trailing \r, the simple

   s/\r$//;

should suffice.

You've could also use

   tr/\r//d;

which removes \r's anywhere in the string, not just at the end.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to