bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:
My first question is how do I shorten this code, I wanted to do something like this...#!/usr/bin/perl use strict; use File::Find; my $file; find( \&wanted, '/tmp/test' ); print "$file\n"; sub wanted { $dir = $File::Find::name if ( /hello\.txt/ ); }
So, it is complaining that it is not able to create the sub named "".... find( \&{ $dir = $File::Find::name if ( /hello\.txt/ ) }, '/tmp/test' );
#!/usr/bin/perl use strict; use File::Find; my $dir = find( \&wanted, '/tmp/test' ); print "$dir\n"; sub wanted { return $File::Find::name if ( /hello\.txt/ ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 2 Questions on File::Find
by ikegami (Patriarch) on Jul 17, 2009 at 22:07 UTC | |
|
Re: 2 Questions on File::Find
by psini (Deacon) on Jul 17, 2009 at 22:07 UTC | |
|
Re: 2 Questions on File::Find
by Marshall (Canon) on Jul 17, 2009 at 22:27 UTC | |
|
Re: 2 Questions on File::Find
by CountZero (Bishop) on Jul 18, 2009 at 19:28 UTC |