Well, having been bitten by this once too often, I have endevoured to
fix a minor problem in the "new FileHandle" routine. Specificly using a
mode of "r+", or "+r", gets translated to "<", NOT "+<" as desired. Also
looking at the code, it seems that the POSIX module expects the "+"
character in front (i.e. perl convention), while as far as I can tell,
the POSIX spec (which I don't have, so I may be wrong on this bit),
expects the "+" at the end. The appended patch changes one line (to fix
the "+r" bug), and adds one line (to move the trailing "+" to the
front). Hopefully we can get this in the next patch level, and not have
to bother with it again.
sjb.
Here is the patch:
*** POSIX.pm.orig Wed Aug 2 14:32:08 1995
--- POSIX.pm Tue Aug 29 11:17:03 1995
***************
*** 298,306 ****
POSIX::usage "FileHandle->new(filename, posixmode)" if @_ != 3;
local($class,$filename,$mode) = @_;
local($glob) = &POSIX::gensym;
$mode =~ s/a.*/>>/ ||
$mode =~ s/w.*/>/ ||
! ($mode = '<');
open($glob, "$mode $filename") and
bless \$glob;
}
--- 298,307 ----
POSIX::usage "FileHandle->new(filename, posixmode)" if @_ != 3;
local($class,$filename,$mode) = @_;
local($glob) = &POSIX::gensym;
+ $mode =~ s/\+// && $mode =~ s/^/+/;
$mode =~ s/a.*/>>/ ||
$mode =~ s/w.*/>/ ||
! $mode =~ s/r.*/</;
open($glob, "$mode $filename") and
bless \$glob;
}
fix a minor problem in the "new FileHandle" routine. Specificly using a
mode of "r+", or "+r", gets translated to "<", NOT "+<" as desired. Also
looking at the code, it seems that the POSIX module expects the "+"
character in front (i.e. perl convention), while as far as I can tell,
the POSIX spec (which I don't have, so I may be wrong on this bit),
expects the "+" at the end. The appended patch changes one line (to fix
the "+r" bug), and adds one line (to move the trailing "+" to the
front). Hopefully we can get this in the next patch level, and not have
to bother with it again.
sjb.
Here is the patch:
*** POSIX.pm.orig Wed Aug 2 14:32:08 1995
--- POSIX.pm Tue Aug 29 11:17:03 1995
***************
*** 298,306 ****
POSIX::usage "FileHandle->new(filename, posixmode)" if @_ != 3;
local($class,$filename,$mode) = @_;
local($glob) = &POSIX::gensym;
$mode =~ s/a.*/>>/ ||
$mode =~ s/w.*/>/ ||
! ($mode = '<');
open($glob, "$mode $filename") and
bless \$glob;
}
--- 298,307 ----
POSIX::usage "FileHandle->new(filename, posixmode)" if @_ != 3;
local($class,$filename,$mode) = @_;
local($glob) = &POSIX::gensym;
+ $mode =~ s/\+// && $mode =~ s/^/+/;
$mode =~ s/a.*/>>/ ||
$mode =~ s/w.*/>/ ||
! $mode =~ s/r.*/</;
open($glob, "$mode $filename") and
bless \$glob;
}