Sun Jan 18 16:50:51 2015: Request 101569 was acted upon. Transaction: Correspondence added by david.trzcin...@skipfault.com Queue: Module-ScanDeps Subject: Re: [rt.cpan.org #101569] Incorrect module parsing if Moose is included Broken in: (no value) Severity: (no value) Owner: Nobody Requestors: david.trzcin...@skipfault.com Status: open Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=101569 >
Hi Roderich, Not sure why the attachment didn't come through correctly. I'm using the following code as a quick test : use Modern::Perl; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; use Fcntl qw(:flock); use strict; use warnings; use AI::Categorizer; use AI::Categorizer::Collection::Files; use Algorithm::NaiveBayes::Model::Frequency; use File::Spec; use File::Copy; use File::ChangeNotify; use AI::Categorizer::Learner::NaiveBayes; use List::MoreUtils::PP; and the complete code is : #!/usr/bin/perl use Modern::Perl; no warnings; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # do singleton check and possible bailout as early as possible. use Fcntl qw(:flock); my $lockfile = 'E:\\FlowData\\PreProcess\\classifier.lock'; sub BailOut { print "$0 is already running. Exiting.\n"; exit(1); } open( my $fhpid, '>>', $lockfile ) or die "error: open '$lockfile': $!"; flock( $fhpid, LOCK_EX | LOCK_NB ) or BailOut(); use strict; no warnings; use AI::Categorizer; use AI::Categorizer::Collection::Files; use Algorithm::NaiveBayes::Model::Frequency; use File::Spec; use File::Copy; use File::ChangeNotify; our $cat_file = 'E:\\FlowData\\PreProcess\\cats.txt'; our $path = 'E:\\FlowData\\ALL'; my $watcher = File::ChangeNotify->instantiate_watcher( directories => [$path], filter => qr/\.(?:xml)$/, ); use AI::Categorizer::Learner::NaiveBayes; our %files; our $nb = AI::Categorizer::Learner::NaiveBayes->restore_state('E:\\FlowData\\PreProcess\\state'); print "Begining to watch $path for changes.\n"; while ( my @events = $watcher->wait_for_events() ) { print "New files have been detected.\n"; open my $out_fh, '>', $cat_file; opendir( DIR, $path ) or die $!; while ( my $file = readdir(DIR) ) { # Use a regular expression to ignore files beginning with a period next if ( $file =~ m/^\./ ); print {$out_fh} "$file \n"; } closedir(DIR); close $out_fh; my $c = new AI::Categorizer::Collection::Files( path => $path, category_file => $cat_file ); while ( my $document = $c->next ) { my $hypothesis = $nb->categorize($document); print "Classified ", $hypothesis->document_name(); print " as ", $hypothesis->best_category, "\n"; my $original = $path . "\\" . $hypothesis->document_name(); my $classified = 'E:\\FlowData\\PreProcess\\'.$hypothesis->best_category().'\\'.$hypothesis->document_name(); if ( $original =~ /^(.*)$/ ) { $original = $1; # $data now untainted } else { die "Bad data in $original"; # log this somewhere } if ( $classified =~ /^(.*)$/ ) { $classified = $1; # $data now untainted } else { die "Bad data in $classified"; # log this somewhere } move( $original, $classified ); } } > <URL: https://rt.cpan.org/Ticket/Display.html?id=101569 > > > On 2015-01-15 23:59:55, david.trzcin...@skipfault.com wrote: >> Example code attached > > It's missing... > I can't reproduce the problem with a simplistic > > scandeps -c -e 'use File::ChangeNotify;' > > > Cheers, Roderich >