in reply to Execution hangs on File::Find

Just a couple thoughts.

I would start with a debugging stacktrace:

use Carp; $SIG{ALRM} = sub { Carp::cluck("HERE") }; alarm 10; # ... now proceed with files

This would print a stacktrace after 10 seconds of execution, providing pointers about where the code is.

Alternatively you can bind to $SIG{INT} and press Ctrl-C to see where you are. Or you can use $logger->info(Carp::longmess("HERE")); instead or cluck.

Also I'm wondering whether the script has a use strict; in it. Because if it doesn't, debugging becomes twice as hard.

Replies are listed 'Best First'.
Re^2: Execution hangs on File::Find
by colox (Sexton) on Dec 04, 2017 at 12:14 UTC

    invoking it within the sub function & log.

    sub Get_FileList{ @files=(); @todel=(); $logger->info(Carp::longmess("TRACE1")); find (sub { $logger->debug("Reached $File::Find::name"); $logger->info(Carp::longmess("TRACE2")); push @files,$File::Find::name if (-f $File::Find::name and + /\.*$/ and stat($File::Find::name)->mtime > $lastepoch); push @todel,$File::Find::name if (-d $File::Find::name);}, + $indir); $logger->info(Carp::longmess("TRACE3")); $lastepoch = time; #Update last execution time for the next run $logger->info("New execution time update: $lastepoch."); $proccount = scalar(@files); $logger->info("Found $proccount new files since last run."); }

    logging below. i guess it is really getting stuck when it tries to traverse the mapped drive

    04-12-2017 04:06:56:570 INFO TRACE1 at perl.pl line 85. 04-12-2017 04:06:56:577 DEBUG Reached Z:/ 04-12-2017 04:06:56:577 INFO TRACE2 at C:/Strawberry/perl/lib/File/F +ind.pm line 358. File::Find::_find_dir(HASH(0x5174bd8), "Z:/", 1) called at C:/Stra +wberry/perl/lib/File/Find.pm line 236 File::Find::_find_opt(HASH(0x5174bd8), "Z:/") called at C:/Strawbe +rry/perl/lib/File/Find.pm line 760 File::Find::find(CODE(0x4e8b7b8), "Z:/") called at perl.pl line 11 +8 main::Get_FileList() called at perl.pl line 85
Re^2: Execution hangs on File::Find
by colox (Sexton) on Dec 04, 2017 at 11:53 UTC

    thank you. let me try this. this is something new to me.