Wednesday 4 September 2019

How many ways to return values in perl subroutine?

Method1:

        sub A
        {
              ($a,$b)=@_;
              return $a+$b;
        }
$B=A(1,2);


Method 2:

       sub A
        {
              ($a,$b)=@_;
              return $a,$b;
        }
$B=A(1,2);


Method 3:

       sub A
        {
              return @_;
        }
@B=A(@a);


Method 4:

       sub A
        {
              return  %H;
        }

%Hash = A;


0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home