[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: binmode

From: Tim Van Holder
Subject: Re: binmode
Date: Thu, 20 Sep 2001 16:04:11 +0200

> Hence, IMHO, SUPER is totally superfluous: there is no difference.

OK, I'll drop the SUPER.

> Maybe you want to check whether open is asked to open an output or
> input file.

That's what the '$_ =~ /^\b*>/' was for.  I suppose I could also use
fcntl, as you suggested, to deduce it after the open.  Not sure if
that's necessarily better though.

> There are certainly means to know a posteriori whether a file is used
> as output.

That won't help here:

        system ("m4 --blah <in >out");

"out" is never opened as a Perl file, so I can't change it's mode.
Since M4 uses text mode for in- and output (IIRC), this results in
a DOS text file on DOS, resulting in a non-Unix-compatible configure
script.  I can either check for the system being dos-djgpp and then
adding a 'system ("dtou out");' (or 'system ("recode /crlf../data out")'
for improved portability), or try some other way of getting Unixy
text.  The former is really a hack (possibly a kludge), but the latter
probably involves overhead (in pseudo-perl):

XFile foo("m4 --blah <input |");
my @outputlines = foo->getlines();
print out, @outputlines;

which is probably not very desirable either.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]