note
pobocks
<p>It's almost certainly a scoping problem, as others have said.</p>
<p>Additionally, I'm not sure what you're trying to do in this Wanted. Even if you had proper scoping, you'd still be re-assigning the variable each time you went over it - in the end, you'd just have whatever the last value that matched the test.</p>
<p>Here's a try at something more reasonable:</p>
<code>
my @foundfiles;
sub Wanted {
return unless (-f $_);
# only operate on compiled widgets
/\.wgt$/ or return;
my $file = $_;
chomp ($file);
chomp ($line);
#print $file ." \n" if $file eq $line;
if (lc($line) eq lc($file)){
# Adds the files to the array
push @foundFiles, $File::Find::name;
}
return;
}
</code>
<p>Alternately, you could keep foundfile as a scalar, and append to it thusly:</p>
<c>$foundfile .= "$File::Find::name\n";</c>
<p>Either way, the important thing is that your variable needs to be in a scope where it won't go away before you use it.</p>
<p>These are pretty common errors, and Perl can catch a lot of them. If you aren't already, start putting this code at the top of every Perl program you write:</p>
<code>use strict;
use warnings;</code>
<p>This will catch a LOT of problems before they turn into headaches. For even more detail (at some performance cost, you can <code>use diagnostics;</code></p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-572803">
<code>for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";</code>
</div></div>
874034
874034