I think the issue is as you mentioned exporting find from File::Find::Rule. However File::Find I am not sure I will get that flexibility to search only 1 level depth.
On Thu, Jan 10, 2013 at 6:07 PM, David Precious <dav...@preshweb.co.uk>wrote: > On Thu, 10 Jan 2013 17:56:18 +0530 > punit jain <contactpunitj...@gmail.com> wrote: > > > I need to get all the subdirectories of test and then read the file > > usersettings under that later on to do some processing. I wrote code > > below :- > > #!/usr/bin/perl > > use strict; > > use warnings; > > use File::Basename qw(basename dirname); > > use File::Find qw(find); > > use File::Find::Rule; > [...] > > find( sub { > > print $File::Find::name; > > if ($File::Find::name =~ /Contacts/ && -s > > $File::Find::name > 0 ) { > > print "$File::Find::name"; > > > > # do some processing > > } > > }, $dir); > > > > } > > > > However I get :- > > > > Use of uninitialized value in print at new.pl line 21. > > Use of uninitialized value in pattern match (m//) at new.pl line 22. > > I suspect the issue is likely to be that you're mixing File::Find and > File::Find::Rule - the latter also exports a find() method, so you may > be inadvertently calling File::Find::Rule's find() method, which > doesn't set $File::Find::name. > > I would recommend changing your code to simply use File::Find::Rule > exclusively. Alternatively, call File::Find::find() instead of just > find(). > > > -- > David Precious ("bigpresh") <dav...@preshweb.co.uk> > http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter > www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook > www.preshweb.co.uk/cpan www.preshweb.co.uk/github > > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >