Prototypes : prototype « Subroutine « Perl






Prototypes

   

A prototype tells declare what types of arguments the subroutine should get. 

my $a=5;
my $b=6;
my $c=7;
@list=(100,200,300);
sub myadd($$) {       # myadd requires two scalar arguments
     my($x, $y)=@_;
     print $x + $y,"\n";
}
myadd($a, $b);        # Okay
myadd(5, 4);          # Okay

   
    
    
  








Related examples in the same category

1.Check the prototype
2.Declaration with prototype