Problem mit Subroutine

downset04

Erfahrenes Mitglied
Hallo
der Code funktioniert nicht - ich bekomm da immer so ne warnung - Variable "$file" will not stay shared at - irgendwas stimmt da nicht mit der subroutine?


Code:
sub search{ 
         my $file = shift; 
         use File::Find; 
         find {wanted => \&match, no_chdir => 1}, "/home"; 
         sub match { 
                 return $_ if /$file/; 
    } 
 
 }

thx
 
mach daraus mal (ungetestet):
Code:
use File::Find;

sub search{ 
    my $file = shift;
    find {wanted => sub{match($file)}, no_chdir => 1}, "/home"; 
} 

sub match {
    my ($file) = @_;
    return $_ if /$file/; 
}
 
Zurück