Hello,
I am using Parallel ForkManager and I would like to use a more complex callback to run on finish, so I would like to define it before hand to make my code more readable. When I do this however I get the following error:
I don't understand what's going on. Can somebody explain? Below is a minimal example to reproduce the error:Can't use string ("1") as a subroutine ref while "strict refs" in use +at $HOME/local/perl/lib/perl5/site_perl/5.12.3/Parallel/ForkManager.p +m line 561 (#1) (F) Only hard references are allowed by "strict refs". Symbolic refer +ences are disallowed. See perlref.
use strict; use warnings; use diagnostics; use Parallel::ForkManager; my $pm = new Parallel::ForkManager(2); # This works pm->run_on_finish( sub { print "Hello!\n"; } ); # This doesn't #sub hello { print "Hello!\n"; } #$pm->run_on_finish( &hello ); foreach my $child ( 0 .. 4 ) { my $pid = $pm->start and next; $pm->finish; } $pm->wait_all_children;
In reply to Problem with ForkManager by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |