On Tue, Nov 07, 2006 at 02:08:48PM -0500, Greg London wrote:
>
> So, I'm looking at the files in hexedit, and some of them
> are coming out with 0d 0d 0a patterns.
> I would think the following would correct lone 0d and lone 0a
> to a full return, but it isn't.
>
> Can anyone see why?
>
>
>
> unless(open(FH, "+< $filename")) {
> die "Error: unable to open $filename for conversion";
> return;
> }
> $/ = undef;
> my $input = <FH>;
>
> # convert any \0a not preceded by \0d to \0d\0a
> $input =~ s{(?<!\x0D)\x0A}{\x0D\x0A}g;
> # convert any \0d not followed by \0a to \0d\0a
> $input =~ s{\x0D(?<!\x0A)}{\x0D\x0A}g;
(?<!) is a negative lookbehind. In the second regex, you want a negative
lookahead:
s{\x0D(?!\x0A)}{\x0D\x0A}g;
But I think that you probably want to change 0d 0d 0a to 0d 0a rather than
to 0d 0a 0d 0a, as the extra 0d is most likely the result of an overzealous
unix2dos conversion.
Ronald
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm