Closed ghost closed 2 years ago
I have found out which was the issue
Lines of code later, there was the problem. The same function was invoked with the parameters in the wrong order
It was like this
push @retval, find_files("$path/$file", $callback);
It must be like this
push @retval, find_files($callback, "$path/$file");
About Pearl Design Patterns, Part 2 by Phil Crow, I tried to run Strategy example: list all files in the current directory but I get this error: Undefined subroutine &main::./a.pl called at file.pl line 22.
This is line 22 push @retval, $path if &$callback($path);
And this is the complete code:
!/usr/bin/perl
use strict; use warnings;
my @files = find_files(\&is_hidden, "."); local $" = "\n"; print "@files\n";
sub is_hidden { my $file = shift; $file =~ s!.*/!!; return 0 if ($file =~ /^./); return 1; }
sub find_files { my $callback = shift; my $path = shift; my @retval;
}
What seems to be the trouble?
I am using Strawberry for Windows.
This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread
Beforehand thanks a lot for your valuable help.