[EMAIL PROTECTED] asked:
> I have certain doubts. 
> 
> What's the meaning of " if
> mysubroutine was defined with prototypes and you were trying 
> to disable that" sentence. 
> 
> Could you please elaborate that what's the meaning of this???

When declaring a subroutine, you can optionally also declare
a prototype for it - i.e. the number and type of arguments.

This allows for a limited sort of compile time parameter
checking aswell as parameter type coercion.

For example:

#!/usr/bin/perl -w

use strict;

sub prototyped ($) {
  print "prototyped args: ", join(', ', @_ ), "\n";
}

sub unprototyped {
  print "unprototyped args: ", join(', ', @_ ), "\n";
}

my @args = qw( foo baz bar );

prototyped @args;
unprototyped @args;
&prototyped @args;

__END__

Output:

prototyped args: 3
unprototyped args: foo, baz, bar
prototyped args: foo, baz, bar

The first sub is declared with a prototype to expect a scalar value as the 
first argument. This declaration forces the argument @args into scalar context, 
so that it evaluates to the number of elements in the array, i.e. 3.

Without the prototype, the array is passed as an array to the subroutine.

If you use the old-style subroutine calling syntax with a prepended &, any 
prototypes for the function are disabled.

Please see the perlsub manpage ("perldoc perlsub") for the
gory details on prototypes and subroutine calling syntax.

HTH,
Thomas



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to