The regex must be applied to an existing variable but you are trying to create a new one using
my
and there is an unnecessary brace:
my $dirs1=basename($f);
{
if (my $dirs1 =~ /^task/)
So it should be:
my $dirs1=basename($f);
if ($dirs1 =~ /^task/)
You should also not use the name of an already existing variable (
dirs1
is already used for an array). While this is possible it is bad style and makes finding errors difficult. This is better:
my $file_name=basename($f);
if ($file_name =~ /^task/)
[EDIT]
If you want to process directories recursively you have to call
ProcessDirectory1
for sub directories:
foreach my $f (@dirs1)
{
if (-d $f)
{
ProcessDirectory1($f);
}
else
{
my $filename=basename($f);
}
}
[/EDIT]