chomp not chomping w/ new $/ char 
Author Message
 chomp not chomping w/ new $/ char

I'm working on a Linux system (eventually this program will have to be
cross platform) with a file generated on Windows, so it has 0x0d (or a CR
char) as the eol character, instead of 0x0a.

I changed the eol character to 0x0d by doing $/ = "\r", which seems to work
just fine when I'm reading data in.  It's terminating at the right place,
with a CR at the end of the string.  Then I try to CHOMP the input string.  
According to the "blue camel", chomp should work on whatever the currently
defined eol character in $/ is.

When I chomp a string with a CR at the end, like this: $killed =
chomp($fileinput), and check $killed, it is 1, showing it removed one
character.  However, the CHOMPed string is not changed and is the same
length, with the trailing CR still at the end.

Why isn't CHOMP removing the trailing CR when I've defined that in $/ and
the input line recognizes it as the new eol char?

Is this a bug or undocumented feature?



Tue, 07 Sep 2004 00:42:48 GMT  
 [ 1 post ] 

 Relevant Pages 

1. chomp not chomping?

2. HELP- Perl new comer (chomp)

3. HELP- Perl new comer (chomp)

4. correction to previous post - chomp, not chop!

5. chomp not working

6. CHOMP not working on some servers

7. CHOMP not working

8. Is chomp in perl 4 or not?

9. split a string not only by a single char but also by a string

10. Newbie: sprintf ('%-20s', 48 char string) returns 48 not 20 length string

11. tr/y not deleting chars?

12. backslash escaping not metacharacters in a char class


Powered by phpBB® Forum Software