[Perl-Tracert] Perl question

Gabor Szabo gabor at tracert.com
Tue Jul 24 06:18:40 PDT 2001


when you say 
sub pa () {
...

you say that there is a function pa expecting 0 arguments

if you say 
sub pa {
...

you say that there is a function pa with ANY number of arguments

so you should remove the () from the function definition.


-- Gabor


On 2001.07.24 15:56 Arie Abramovitch wrote:
> Hi
> 
> I have 2 files: my.pl and ub.pm.
> 
> The script pub.pm. contains the function pa() definition as follows:
> ---------------------------------------------------------
> sub pa ()
> {
>          pa_profile(0, scalar(@_), \@_);
> }
> ---------------------------------------------------------
> 
> The script my.pl calls the function pa()  as follows:
> ---------------------------------------------------------
> pa ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
> ---------------------------------------------------------
> 
> The problem:
> When I try to run my.pl script, PERL fails with a compilation error:
> Too many arguments for pub::pa at my.pl line 25, near "9)"
> 
> I moved the definition of pa() to the script my.pl and PERL runs ok.
> 
> My question:
> Why did PERL complain in the first case?
> Why did it stop complaining after placing the function in my.pl?
> What should I do to run the pa() function in its original place (in
> pub.pm)?
> 
> Thanks,


--
Gabor Szabo
http://www.tracert.com/  
Web site monitoing
Web application development 
Perl training




More information about the Perl mailing list