#!/usr/bin/perl
use strict;
use warnings;
sub f($)
{
print 'f called with ',0+@_,' arguments: ',join(', ',@_),"\n";
}
sub g
{
print 'via g: ';
&f;
}
f(42);
&f(42);
&f();
&f(42,99,333);
g(42);
g();
g(42,99,333);
Output:
f called with 1 arguments: 42
f called with 1 arguments: 42
f called with 0 arguments:
f called with 3 arguments: 42, 99, 333
via g: f called with 1 arguments: 42
via g: f called with 0 arguments:
via g: f called with 3 arguments: 42, 99, 333
See perlsub for what happens here, and why perl does not complain.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
|