in reply to CR-LF Newlines as 2 distinct characters
You mentioned playing with $/, but what about $\ (output sep)?
If you're trying to write compatible files (did I understand that correctly?), then why use \n at all? Why not just explicitly write out the EOL string? Like this:
sub plp_writeln { # plp_writeln( $HANDLE, @elem ); # writes @elem joined as one line to the file $HANDLE for .plp my $HANDLE = shift; my @elem = @_; print $HANDLE, @elem, qq[\x{0D}\x{00}\x{0A}\x{00}]; }
Or, similar idea, subbing all newlines for your custom newline:
sub plp_write { # plp_write( $HANDLE, @elem ); # writes @elem to the file $HANDLE for .plp, interpolating newline +s my $HANDLE = shift; my @elem = @_; ( my $str = join('',@elem) )=~s[\n][\x{0D}\x{00}\x{0A}\x{00}]gs; print $HANDLE, $str; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CR-LF Newlines as 2 distinct characters
by blogical (Pilgrim) on May 18, 2006 at 21:09 UTC | |
by radiantmatrix (Parson) on May 18, 2006 at 21:20 UTC |