Subject: | Deltas returned from sub lack internal "owner" attribute |
Running perl 5.22.1
I'm writing a module that returns File::Monitor::Delta objects, but their methods break due to "owner" being undefined. See the attached example code, it should print a file name but instead fails with
Can't call method "_make_absolute"
I suspect "weaken" should only be called if the reference is truly circular. Can fix by changing line 87 of File/Monitor/Object.pm to
weaken $self->{owner} if $self->{owner} == $self;
Subject: | t6_FileMonitor.pl |
#!perl -w
use strict;
use Carp::Always;
use File::Spec;
use File::Monitor;
my $new_file = 'new_file';
# Clean up after last run
unlink $new_file if -f $new_file;
my @results;
# Get a list of of deltas
sub get_deltas {
my $monitor = File::Monitor->new();
$monitor->watch($new_file);
$monitor->scan;
# Create the thing we're looking for & return it
open NEW,'>',$new_file; close NEW;
return $monitor->scan;
}
@results = get_deltas;
for (@results) {
print $_->name; # This gives an error
}
# Clean up, if the above passes :-)
unlink $new_file;