in reply to issue with LF & CRLF
I have managed to diagnose there is LF in the middle of line and the normal CRLF in the end. how can i remove this LF.
You can use a negative look-behind assertion to remove each LF that is not immediately preceded by a CR:
#! perl use strict; use warnings; my $string = qq{"Tap Rackmount for 3 units\x0A","USR4500-RMK " +\x0D\x0A}; print "Before:\n>>>$string<<<\n"; # Dec Hex Oct # LF 10 0A 012 # CR 13 0D 015 $string =~ s/ (?<!\x0D) \x0A //gx; print "After:\n>>>$string<<<\n";
Output:
12:49 >perl 679_SoPW.pl Before: >>>"Tap Rackmount for 3 units ","USR4500-RMK " <<< After: >>>"Tap Rackmount for 3 units","USR4500-RMK " <<< 12:49 >
See the section “Look-Around Assertions” in perlre#Extended-Patterns.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|