On Mar 3, 2006, at 1:21 a, Tom Phoenix wrote:
On 3/2/06, Timothy Driscoll <[EMAIL PROTECTED]> wrote:
sub get_all_files :Export(:DEFAULT)
{
my ($cwd, $ext, @list_of_files);
$ext = shift;
$cwd = shift;
$ext = 0 unless defined $ext;
$cwd = `pwd` unless defined $cwd;
chomp $cwd;
sub wanted_files
{
my $infile = $File::Find::name;
my @parts = split(/\./, $infile);
if (!$ext || (pop(@parts) eq $ext)) {
Here's the trouble. I found it when I tried running your code with
warnings enabled. (Had you tried that? If you're using the 'use
warnings' pragma, remember it's lexical, and needs to be mentioned
again in each file.)
hi Tom,
yes, I saw that error message - my mistake for not including it in
the original email.
The solution is probably to change the inner sub from named to
anonymous. (As I understand it, calling an anonymous subroutine causes
perl to rebind the variables, but a named sub doesn't.) Does that fix
the problem for you?
thanks! yes, this seems to work ok, and the error message is gone.
One other thought: If you're going to search for several different
file extensions in the same locations, it's generally more efficient
to do a single search for all the extensions, rather than a separate
search for each extension, as was (perhaps wrongly) implied in your
example.
true and, in fact, my initial version of the sub did look for
multiple extensions in a single pass. I whittled it down to a
simpler case for debugging. I'm still quite the Perl novice. :-)
thanks a lot for the help,
tim
--
Timothy Driscoll em: [EMAIL PROTECTED]
Virginia Bioinformatics Institute ph: 540-231-3007
Bioinformatics I im: molvisions
Washington St., Blacksburg, VA 24061
"Well, it's going to suck today, but at least I'm not getting
smallpox." - Leiws Black
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>