私はこの単純な基本クラス(モジュール)を持っています:
package XMSP::File;
use parent 'IO::File';
sub new {
my ($self,@args) = @_;
my $object = {};
bless($object,$self);
$object->SUPER::new(@args);
return $object;
}
sub open {
my ($self,@args) = @_;
$self->SUPER::open(@args);
}
sub close {
my ($self,@args) = @_;
$self->SUPER::close(@args);
}
1;
脚本:
#!/usr/bin/env perl
use strict;
use warnings;
use XMSP::File;
my $file = XMSP::File->new("< $0");
if (defined $file) {
print "First Ok\n";
$file->close();
}
$file->open("< file");
if (defined $file) {
print "Second Ok\n";
}
私のスクリプトでは、次を使用してロードしuse
ます... ctor(new)を使用して新しいオブジェクトなどを作成しますが、閉じると次のエラーで終了します:
First Ok
Not a GLOB reference at /usr/lib/perl/5.10/IO/Handle.pm line 115.
なぜなのか本当にわかりません。