O
O. Olson
Hi,
I would like to know if it is possible to enforce the number and type
of the parameters in a function prototype. Assuming that a person does
not circumvent the prototypes using &.
I have tried the following that tries to say that the function
printScalar () should only accept a single Parameter. This does not
work i.e. does not compile.
# This function would print the time variable passed
sub printScalar(my $num)
{
print "$num";
}
I have looked at perlsub at http://perldoc.perl.org/perlsub.html - and
I am not sure if the answer to my Question is NO.
This would be of more importance when I am working with Objects i.e.
to ensure that the reference passed, is an object of a certain class.
Thanks a lot.
O.O.
I would like to know if it is possible to enforce the number and type
of the parameters in a function prototype. Assuming that a person does
not circumvent the prototypes using &.
I have tried the following that tries to say that the function
printScalar () should only accept a single Parameter. This does not
work i.e. does not compile.
# This function would print the time variable passed
sub printScalar(my $num)
{
print "$num";
}
I have looked at perlsub at http://perldoc.perl.org/perlsub.html - and
I am not sure if the answer to my Question is NO.
This would be of more importance when I am working with Objects i.e.
to ensure that the reference passed, is an object of a certain class.
Thanks a lot.
O.O.