the Shout.pm and demonstration code in pperl3 pp 385-389 elicit a rather
obfuscated error message
"Can't use an undefined value as filehandle reference at ..."
under 5.6.1 (activeperl / cygwin).
Following is a minimal illustration :
#!perl -w
package Myfile;
use Carp;
require Tie::Handle;
@ISA = (Tie::Handle);
sub TIEHANDLE {
use Symbol;
my $class = shift;
my $form = shift;
open my $self, $form, @_ or croak "can't open $form@_: $!";
return bless $self, $class;
}
sub CLOSE {
my $self = shift;
return close $self;
}
# ... more methods
package main;
tie(*FOO, Myfile::, "+>foo.tmp");
# ...
close FOO;
The problem lies in the "open" line
open my $self, $form, @_ or croak "can't open $form@_: $!";
in conjunction with the form
tie(*FOO, Myfile::, "+>foo.tmp");
Using the alternate form
tie(*FOO, Myfile::, "+>", "foo.tmp");
does not elicit an error, but constraining client code this way is
harly acceptable.
Changing the "open" line above into
my $self;
if (@_) {
open $self, $form, @_ or croak "can't open $form@_: $!";
} else {
open $self, $form or croak "can't open $form: $!";
}
is better but beyond uglyness... There must exist a better way.
Any taker ?
Also, the error message sounds a bit off-topic, which might indicate a
problem in 'open' itself. However I don't know who this should be reported
to, nor how. Any pointers ?
TIA,
--Christian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]