in reply to Re^2: Strange character beginning text files
in thread Strange character beginning text files
And it only does this when the string matching $/ happens to occur at the end of the scalar value being chomped.
Update: Honest, I really did (start to) post this before tachyon made it redundant. And I confess I was not speaking from personal experience (lucky me) about the default value of $/ on ms-win -- thanks to tachyon for the correction.perl -e '$/ = "\n"; $_ = "str\015\012"; chomp; s/(\s)/sprintf("%o",ord +($1))/eg; print $_,$/' # prints "str15" perl -e '$/ = "\r\n"; $_ = "str\015\012"; chomp; s/(\s)/sprintf("%o",o +rd($1))/eg; print $_,$/' # prints "str" perl -e '$/="\r\n"; $_ = "foo\015\012str\015\012"; chomp; s/(\s)/sprin +tf("%o",ord($1))/eg; print $_,$/' # prints "foo1512str"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Strange character beginning text files
by tachyon (Chancellor) on Jul 20, 2004 at 05:26 UTC | |
by wfsp (Abbot) on Jul 20, 2004 at 07:28 UTC | |
|
Re^4: Strange character beginning text files
by tachyon (Chancellor) on Jul 20, 2004 at 05:17 UTC |