thesundayman has asked for the wisdom of the Perl Monks concerning the following question:
When one store text in an MSSQL server text field it replaces the new lines with \r\r\n and it confuses perl when i take it out again and parse it. however the following code fixes it ... I takes the text field from sql server store it in a file, then i apply the following code on it, and the text file turns back to normal
open(IN, "$ARGV[0]") || die "unable to open $ARGV[0]"; open(OUT, ">$ARGV[1]") || die "unable to open $ARGV[0]"; binmode(OUT); #set output mode as binary while(<IN>) { if(/^\n$/) { print OUT "\r\n"; # if this the record separator, print a proper + line } else { print OUT; } # else just print line with a CR } close(IN); close(OUT);
but how does that work
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can anyone figure how this works?
by chromatic (Archbishop) on Sep 29, 2001 at 22:40 UTC | |
|
Re: Can anyone figure how this works?
by tachyon (Chancellor) on Sep 29, 2001 at 22:51 UTC | |
by demerphq (Chancellor) on Sep 30, 2001 at 05:38 UTC | |
by tachyon (Chancellor) on Sep 30, 2001 at 22:10 UTC | |
by thesundayman (Novice) on Oct 03, 2001 at 14:57 UTC | |
by tachyon (Chancellor) on Oct 03, 2001 at 18:49 UTC |