L
Larry
I have the following code:
open STDERR, ">>", ".log.txt";
if ( $ENV{"REQUEST_METHOD"} eq 'HEAD' )
{
close(STDIN);
if($ENV{"HTTP_USER_AGENT"})
{
if(&_check_header_password($ENV{"HTTP_USER_AGENT"}))
{
print "Status: 200 OK\n\n";
} else {
print "Status: 401 Wrong Password\n\n";
}
}
exit;
}
sub _check_header_password
{
my $pswd = shift;
my $pswdfile = '_pswd.txt';
my $header_pswd; ($header_pswd) = ($pswd =~ /<pwd>(.*?)<\/pwd>/sg);
if (-e $pswdfile)
{
my $savedpswd;
{open my $fh1, '<', $pswdfile or die "$pswdfile $!";undef
$/;$savedpswd = <$fh1>;close $fh1;};
if ($header_pswd eq $savedpswd) { return 1; } else { return 0; }
} else {
open my $fh1, ">", $pswdfile or die "$!";
print $fh1 $header_pswd;
close $fh1;
return 1;
}
}
__END__;
it fires thi error/warn: "Filehandle STDIN reopened as $fh1 only for
output"
this seems to happen when it encounters this: open my $fh1, ">",
$pswdfile or die "$!";
what am I actually doing wrong?
thanks
open STDERR, ">>", ".log.txt";
if ( $ENV{"REQUEST_METHOD"} eq 'HEAD' )
{
close(STDIN);
if($ENV{"HTTP_USER_AGENT"})
{
if(&_check_header_password($ENV{"HTTP_USER_AGENT"}))
{
print "Status: 200 OK\n\n";
} else {
print "Status: 401 Wrong Password\n\n";
}
}
exit;
}
sub _check_header_password
{
my $pswd = shift;
my $pswdfile = '_pswd.txt';
my $header_pswd; ($header_pswd) = ($pswd =~ /<pwd>(.*?)<\/pwd>/sg);
if (-e $pswdfile)
{
my $savedpswd;
{open my $fh1, '<', $pswdfile or die "$pswdfile $!";undef
$/;$savedpswd = <$fh1>;close $fh1;};
if ($header_pswd eq $savedpswd) { return 1; } else { return 0; }
} else {
open my $fh1, ">", $pswdfile or die "$!";
print $fh1 $header_pswd;
close $fh1;
return 1;
}
}
__END__;
it fires thi error/warn: "Filehandle STDIN reopened as $fh1 only for
output"
this seems to happen when it encounters this: open my $fh1, ">",
$pswdfile or die "$!";
what am I actually doing wrong?
thanks