Ok, thanks to "John W. Krahn" and "A. Sinan Unur" for the
fast replies to my post.
I'd written:
> > #!/bin/perl
> > open my $F, $0 or die $!;
> > while (<$F>)
> > {
> > chomp;
> > print ("one two three " . "$_" . " DEF \n");
> > }
> > close $F;
> > ...
> > djgpp Perl outputs:
> > DEF wo three #!/bin/perl
> > DEF wo three open my $F, $0 or die $!;
> > DEF wo three while (<$F>)
> > DEF wo three {
> > DEF wo three chomp;
> > DEF wo three print ("one two three " . $_ . " DEF \n");
> > DEF wo three }
> > DEF wo three close $F;
> > What's going on there???...
and John replied:
> Your perl program is stored on disk in a DOS text format that
> has a carriage return and line feed at the end of the line and
> the djgpp version's chomp() removes these correctly however
> cygwin is a UNIX enviroment so it only removes the line feed
> but not the carriage return.
AH, I see it clearly now. The LF is gone but the CR remains, so
the print cursor obediantly goes to start of same line and starts
over-writing.
Perhaps I should get a unixy editor for use with cygwin... but
then my files would look like crud in notepad; and if I use
NoteTab (my favorite editor) instead, it'll change all the LFs
back to CRLFs anyway.
I think I'll alter chomp in the Perl source and recompile.
::: Reads source :::
How come this is full of Tolkien quotes? Not that I'm
complaining. Mithril and elven glass suit me fine.
A. Sinan Unur wrote:
> s/(
\015\012)|(
\015)|(
\012)//
Ok, cool chomp replacement. Basically, "replace CRLF, CR,
or LF with empty substring".
But what is this "

" thingy? I'd read that RE as meaning
"zero-or-one colons", which doesn't seem to make sense in
this context.
::: reads
www.perl.org man pages :::
Ah, I see... you meant non-capture grouping:
s/(?:\015\012)|(?:\015)|(?:\012)//
If you switch the ':' and '?', it's still a valid RE, but
it then means something very different!
Or just take out the groupings and chomp all CRs and LFs:
s/[\015\012]//g;
or even:
s/[\n\r]//g;
Cheers,
Robbie Hatley