A
Alex
Hello,
I want a function to be private inside a module, so - I made it
anonymous. Also I want it to be recursive - how to do that?
use diagnostics;
use warnings;
use strict;
my $F1 = sub($)
{
my $n = shift;
print "$n\n";
$F1->($n + 1) if $n < 10;
};
F1(0);
This gives me the error message:
------------------------
Global symbol "$F1" requires explicit package name at tp205.pl line
27.
Execution of tp205.pl aborted due to compilation errors (#1)
(F) You've said "use strict vars", which indicates that all
variables
must either be lexically scoped (using "my"), declared beforehand
using
"our", or explicitly qualified to say which package the global
variable
is in (using "::").
Uncaught exception from user code:
Global symbol "$F1" requires explicit package name at tp205.pl line
27.
Execution of tp205.pl aborted due to compilation errors.
at tp205.pl line 30
I want a function to be private inside a module, so - I made it
anonymous. Also I want it to be recursive - how to do that?
use diagnostics;
use warnings;
use strict;
my $F1 = sub($)
{
my $n = shift;
print "$n\n";
$F1->($n + 1) if $n < 10;
};
F1(0);
This gives me the error message:
------------------------
Global symbol "$F1" requires explicit package name at tp205.pl line
27.
Execution of tp205.pl aborted due to compilation errors (#1)
(F) You've said "use strict vars", which indicates that all
variables
must either be lexically scoped (using "my"), declared beforehand
using
"our", or explicitly qualified to say which package the global
variable
is in (using "::").
Uncaught exception from user code:
Global symbol "$F1" requires explicit package name at tp205.pl line
27.
Execution of tp205.pl aborted due to compilation errors.
at tp205.pl line 30