in reply to Re: Strange character beginning text files
in thread Strange character beginning text files
Actually chomp typically eats \n only which is the line feed char LF not the carriage return char CR....
printf "CR \\r \\%03o 0x%02x\n", ord("\r"), ord("\r");; printf "LF \\n \\%03o 0x%02x\n\n", ord("\n"), ord("\n");; my $str = "str\015\012"; for( 1..2 ) { print "string '$str'\n"; print "length ", length $str, "\n"; chomp $str; print "string '$str'\n"; print "length ", length $str, "\n\n"; }
Technically chomp removes any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in the English module).
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Strange character beginning text files
by graff (Chancellor) on Jul 20, 2004 at 05:12 UTC | |
by tachyon (Chancellor) on Jul 20, 2004 at 05:26 UTC | |
by wfsp (Abbot) on Jul 20, 2004 at 07:28 UTC | |
by tachyon (Chancellor) on Jul 20, 2004 at 05:17 UTC |