Suresh Govindachar wrote:
> Steve wrote as a deprecated top post:
> > $Bill wrote:
> >> Suresh Govindachar wrote:
> >>>
> >>> [almost working code]
> >>
> >> Try:
> >> > $^I = '~'; no warnings 'once';
> >> while (<>) { binmode ARGVOUT if $. == 1; print; }
> >
> >The following worked -- didn't need to turn off warnings.
> >
> > #!/usr/bin/perl
> > BEGIN {(*STDERR = *STDOUT) || die;}
> > use diagnostics;
> > use warnings;
> > use strict;
> > $| = 1;
> >
> > $^I = '~';
> > while (<>)
> > {
> > binmode ARGVOUT if $. == 1; s/\r\n$/\n/;
> > print;
> > }
> >
> >And the one-liner becomes:
> >
> > perl -i~ -pe "binmode ARGVOUT if $.==1; s/\r\n$/\n/;" <dossy files>
> >
> >
> > What about Ctrl-Z? Ctrl-Z at the end of a DOS file is another
> > difference between DOS and Unix files.
Windoze no longer uses ^Z markers - the above one-liner will leave
any ^Z's in the file.
> Not sure. The VIM text editor, by default, includes an
> end-of-file marker on any OS.
That's news to me.
> Wouldn't a text file in unix format on Windows still have a
> Windows end-of-file marker?
There are no EOF markers.
> How do you know whether or not a file has an end-of-file marker
> and if it does, what the marker is (^Z? ^D? something else?).
There shouldn't be any except on old DOSified files in which case
you could remove them or just ignore them.
> Did you try either version of the perl code on a dossy file, and
> if so, did the end-of-file marker vanish?
There's nothing in the script that would remove one.
> Please provide examples of a dossy file and two unix'ified
> versions it, one with the end-of-file maker and the other without.
It'll be hard finding a text file with a ^Z in it.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs