On 27 April 2010 15:39, dbtouch <dbto...@gmail.com> wrote: > Hi, Perl Folks
Hello. > I am getting error "Too many arguments for > OneTickUtil::getFilesFromDir at G:\workspace1\scripts\fooPackage.pl > line 4, near "$pattern)" when running a small script calling a package > routine. Could you give some ideas on what I did wrong? > > Thanks, > > db > > # OneTickUtil.pm > use File::Find; > use Date::Calc qw(:all); > use File::Path; > > ############################################################## > # OneTickUtil > # > # Some classes and functions to use in omd examples > ############################################################## > > package OneTickUtil; > > our $Dir; > our $searchPattern; > > sub getFilesFromDir() This is the cause of that error. Your have, I imagine unwittingly, created a prototype. This says I want a function called getFileFromDir and have it accept no argument (). You are passing in 2 arguments, $dir and $patten. If you remove the brackets, it will remove that error. If you want to use prototypes you would have done sub getFilesFromDir($$) but I would not recommend that approach. Another major concern is that you have created a package and not used strict or warning. If you are going to create a package, you should make your variables private, particualrly as you have already declared some variables (EG: our $Dir). Have a read of perlsub (perldoc perlsub) for information on perl subroutines. It also talks about private variables. Good luck. Dp. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/