CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
File::Find Not a code reference at line 822

 



charlicon
New User

Nov 2, 2007, 12:51 PM

Post #1 of 5 (257 views)
File::Find Not a code reference at line 822 Can't Post

Hi Guys,

I just installed File::Find from the cpan shell, no obvios errors.

However, when I try to run a test script, the perl complier gives me this error,


Code
Note a code reference at /usr/lib/perl5/5.8.8/File/File.pm line 822


The file im trying to run goes as follows,


Code
#!/usr/bin/perl 
#
use File::Find;

find(\$print_name_if_dir, ".");

sub print_name_if_dir
{
print if -d;
}


I looked the the File.pm file, and line 822 fell into the following block, it doesn't shed any light on the problem for me, but I am a newbie at all this!


Code
 while (defined $SE) { 
unless ($bydepth) {
$dir= $p_dir; # $File::Find::dir
$name= $dir_name; # $File::Find::name
$_= ($no_chdir ? $dir_name : $dir_rel ); # $_
# prune may happen here
$prune= 0;
{ $wanted_callback->() }; # protect against wild "next"
next if $prune;
}


Any help would be greatly appreciated!!

Thanks.


KevinR
Veteran


Nov 2, 2007, 1:10 PM

Post #2 of 5 (254 views)
Re: [charlicon] File::Find Not a code reference at line 822 [In reply to] Can't Post

this:

find(\$print_name_if_dir, ".");

should be:

find(\&print_name_if_dir, ".");
-------------------------------------------------


charlicon
New User

Nov 2, 2007, 1:29 PM

Post #3 of 5 (251 views)
Re: [KevinR] File::Find Not a code reference at line 822 [In reply to] Can't Post

Man those lil' typos are *so* annoying!


Wasell
New User

Nov 4, 2007, 12:13 AM

Post #4 of 5 (243 views)
Re: [charlicon] File::Find Not a code reference at line 822 [In reply to] Can't Post


Quote
Man those lil' typos are *so* annoying!


And that's why the Good Larry gave us strictures and warnings! Always start your programs with:

Code
use strict; 
use warnings;

In this case, perl would have complained about 'Global symbol "$print_name_if_dir" requires explicit package name...'.


KevinR
Veteran


Nov 4, 2007, 12:36 AM

Post #5 of 5 (242 views)
Re: [Wasell] File::Find Not a code reference at line 822 [In reply to] Can't Post


Quote
Always start your programs with:

Code
use strict; 
use warnings;



I totally agree.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives