Open In App

Perl | prototype() Function

Improve
Improve
Like Article
Like
Save
Share
Report

prototype() function in Perl returns a string containing the prototype of the function or reference passed to it as an argument, or undef if the function has no prototype.

Syntax: prototype(function_name)

Parameter:
function_name: Function whose prototype is to be determined

Returns:
prototype of the function passed or undef if no prototype exists

Example 1:




#!/usr/bin/perl -w
  
$prototype_func = prototype ( "GFG" );
print "Prototype of GFG function "
            "is $prototype_func\n";
  
sub GFG(**) 
{
    print "Just a statement\n";
}


Output:

Prototype of GFG function is **

Example 2:




#!/usr/bin/perl -w
  
$prototype_func = prototype ( "GFG" );
print "Prototype of GFG function "
            "is $prototype_func\n";
  
sub GFG($$) 
{
    print "Just a statement\n";
}


Output:

Prototype of GFG function is $$

Last Updated : 28 Feb, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads